Lithosphere Infrastructure Configuration

This directory contains all infrastructure-related configuration files for the Lithosphere Makulu deployment.

Directory Structure

infra/
├── alertmanager/          # Alertmanager configuration
│   └── alertmanager-config.yaml

├── grafana/               # Grafana provisioning & dashboards
│   ├── provisioning/
│   │   ├── datasources/
│   │   │   └── datasources.yaml
│   │   └── dashboards/
│   │       └── dashboards.yaml
│   └── dashboards/
│       ├── system-overview.json
│       ├── api-monitoring.json
│       └── container-metrics.json

├── k8s/                   # Kubernetes manifests (future)
│   └── base/
│       └── kustomization.yaml

├── loki/                  # Loki log aggregation
│   └── loki-config.yaml

├── postgres/              # PostgreSQL initialization
│   └── init.sql

├── prometheus/            # Prometheus metrics & alerts
│   ├── prometheus.yml
│   └── alerts/
│       └── lithosphere-alerts.yml

└── promtail/              # Promtail log collection
    └── promtail-config.yaml

Configuration Files

Alertmanager

File: alertmanager/alertmanager-config.yaml

Handles alert routing and notifications. Currently configured with console output.

To enable Slack notifications:

  1. Create a Slack webhook URL

  2. Uncomment the slack_configs section

  3. Add your webhook URL

  4. Restart Alertmanager

To enable email notifications:

  1. Configure SMTP settings in the global section

  2. Uncomment email receivers

  3. Restart Alertmanager

Grafana

Provisioning: grafana/provisioning/

  • Automatically configures datasources (Prometheus, Loki)

  • Loads dashboards from grafana/dashboards/

Pre-configured Dashboards:

  1. System Overview - VPS health (CPU, RAM, Disk, Network)

  2. API Monitoring - Request rates, latencies, errors, logs

  3. Container Metrics - Docker container resource usage

Custom Dashboards:

  • Create JSON files in grafana/dashboards/

  • They will be auto-loaded on Grafana restart

Loki

File: loki/loki-config.yaml

Log aggregation and storage configuration.

Key Settings:

  • Retention: 30 days (720 hours)

  • Max ingestion rate: 4 MB/s

  • Storage: Filesystem (/loki)

To adjust retention:

Prometheus

File: prometheus/prometheus.yml

Metrics collection and scrape configuration.

Monitored Targets:

  • Lithosphere API (port 9090)

  • Lithosphere Indexer (port 9090)

  • Node Exporter (port 9100) - VPS metrics

  • cAdvisor (port 8080) - Container metrics

  • Docker containers with prometheus.scrape=true label

Alert Rules: prometheus/alerts/lithosphere-alerts.yml

Defines alert conditions for:

  • Service health (API down, Indexer down, DB down)

  • Performance issues (high latency, error rates)

  • Resource usage (CPU, memory, disk)

  • Container issues (restarts, high resource usage)

To add custom alerts:

  1. Edit lithosphere-alerts.yml

  2. Follow Prometheus alert syntax

  3. Reload Prometheus: curl -X POST http://localhost:9091/-/reload

Promtail

File: promtail/promtail-config.yaml

Log collection agent that ships logs to Loki.

Log Sources:

  • Docker container logs (/var/lib/docker/containers)

  • System logs (/var/log/syslog)

  • Auto-discovered containers with monitoring labels

Pipeline:

  1. Collects logs from sources

  2. Parses JSON logs

  3. Extracts labels (service, environment, level)

  4. Ships to Loki

PostgreSQL

File: postgres/init.sql

Database initialization script.

Creates:

  • Required extensions (uuid-ossp, pg_trgm)

  • transfers table for LEP-100 events

  • blocks table for block metadata

  • Indexes for query optimization

Kubernetes (Future)

Directory: k8s/

Placeholder for Kubernetes manifests when deploying to K8s clusters.


Environment Variables

Many configurations can be overridden with environment variables:

Set these in .env file or export them before running Docker Compose.


Maintenance

Updating Configurations

After modifying any config file:

Backup Configurations

Volume Management

Monitoring data is stored in Docker volumes:


Security Considerations

1. Network Exposure

By default, monitoring services are exposed on all interfaces. In production:

Option A: Use firewall rules

Option B: Bind to localhost only

2. Grafana Authentication

Change default password immediately:

3. Alertmanager Secrets

Never commit credentials to version control:


Troubleshooting

Issue: Configuration not loading

Issue: Dashboards not appearing in Grafana

  1. Check provisioning path is correct

  2. Verify JSON syntax: jq . dashboard.json

  3. Check Grafana logs: docker compose logs grafana

  4. Restart Grafana: docker compose restart grafana

Issue: Alerts not firing

  1. Check alert rule syntax in Prometheus UI

  2. Verify Alertmanager is configured in prometheus.yml

  3. Test alert: curl http://localhost:9091/api/v1/rules

  4. Check Alertmanager: curl http://localhost:9093/api/v2/alerts


Performance Tuning

Reduce Disk Usage

Reduce Memory Usage

Optimize Scrape Intervals


Additional Resources

Last updated