Advanced Observability
Zerops Advanced Observability provides one-click, self-hosted, pre-configured deployments of the ELK stack or Prometheus with Grafana. This enables comprehensive observability for your deployments while maintaining full control over your data and infrastructure.
Deployment Modes
Both ELK and Prometheus can be deployed in two ways:
- Local deployment: Services are deployed within your target project
- Global deployment: A dedicated project is created specifically for observability
ELK Stack
The ELK observability setup deploys and configures two base services:
- Elasticsearch (as
elkstorage) - Kibana (as
kibana) - the observability access point
Logging
For log collection with ELK, see the Log Forwarding guide which covers the Logstash setup and configuration.
Tracing
To collect traces in the ELK stack, an APM Server instance (deployed as the apmserver service) is required. APM Server listens for incoming traces securely over HTTPS and indexes them to Elasticsearch.
First, follow the one-click GUI integration setup to deploy the required infrastructure. Then configure your application to send traces to APM Server.
Setting Up APM Agents
-
Update your code according to the APM documentation for your application's language. See this simple Go application using APM libraries for reference.
-
Add the following environment variables to your application service (these are specific to the official Go APM Agent library and may differ for other agents):
The ELASTIC_APM_ACTIVE variable is set to false by default on Zerops, so you must explicitly set it to true to enable APM for the official Go APM agent.
- Restart or reload your application service.
You should start seeing traces appear in Kibana's "Applications > Traces" section.
What Happens Behind the Scenes
- The
elkstorage,kibana, andapmserverservices are deployed and configured in the target project (if not already present) - The
apmserveris made publicly accessible over HTTPS via a Zerops subdomain and configured with a secret token for secure access
Access information for both Kibana and APM Server can be found in the Advanced Observability section of your project in the GUI.
Next Steps
- Security: Set up custom domains for Kibana and APM Server
- Optimization: Connect to APM Server locally via HTTP for improved performance
- Customization: Fork the ELK recipe, customize the Logstash configuration, and redeploy the
logstashservice viazcli
Prometheus with Grafana
The full Prometheus setup consists of:
- Prometheus (as
prometheus) - Grafana (as
grafana) - the observability access point - PostgreSQL database (as
grafanadb) - for Grafana data storage - S3 bucket (as
prometheusbackups) - for storing Prometheus backups
Metrics can be forwarded to the target project via a Prometheus exporter (single prometheuslight service configured with remote write). When present in a source project, it collects metrics and forwards them to Prometheus in the target project.
Since Prometheus supports only filesystem storage and non-HA (single instance) setup, the prometheus service is configured to run a backup cron job that stores metric data snapshots in object storage.
Metrics
After deploying the full or forwarder Prometheus setup, metrics are automatically scraped by Prometheus. After setup completes, log in to Grafana using the credentials found in the Advanced Observability section of your project in the GUI, then navigate to /dashboards to start exploring your metrics.
Zerops provides several metrics out of the box:
- Service scaling and resource metrics
- PostgreSQL database service metrics (with HAProxy balancer metrics in HA setups)
- MariaDB database service metrics
- Valkey database metrics
Some PostgreSQL database metrics are available only after enabling the pg_stat_statements extension. Run CREATE EXTENSION IF NOT EXISTS pg_stat_statements; as a superuser and restart the database service.
You can also expose custom metrics from your applications.
Exposing Custom Metrics
-
Configure your application to expose an HTTP
/metricsendpoint on an arbitrary port. See this simple Go application usingpromautofor reference.NoteOnly the
/metricspath is scraped and cannot currently be configured otherwise. -
Add and commit the
ZEROPS_PROMETHEUS_PORTenvironment variable to your application service with the port where you exposed the/metricsendpoint:
For example: ZEROPS_PROMETHEUS_PORT=9090. After setting the environment variable, your service's ports will be automatically added to metrics discovery and scraped by Prometheus.
What Happens Behind the Scenes
Full setup:
- The
prometheus,grafana,grafanadb, andprometheusbackupsservices are deployed and configured (if not already present) grafanais made publicly accessible over HTTPS, securely accessible via a generated password
After that, metrics are scraped and available for visualization in Grafana.
Forwarder setup:
- The
prometheuslightforwarder service is deployed in the source project - The
prometheus,grafana,grafanadb, andprometheusbackupsservices are deployed and configured in the target project (if not already present) grafanais made publicly accessible over HTTPS, securely accessible via a generated passwordprometheusis made publicly accessible over HTTPS via a Zerops zone domain and secured with basic access authentication (username and password)prometheuslightis configured to forward metrics to the targetprometheususing the generated credentials over secure HTTPS
Next Steps
- Security: Set up custom domains for Grafana and Prometheus
- Customization: Fork the Prometheus recipe, customize dashboards and alerting rules, and redeploy via
zcli - Advanced monitoring: Explore Grafana's alerting capabilities and create custom dashboards for your specific use cases