Raised: $0
0% of monthly goal Help us cross the finish line!
Goal: $12,000
Raised: $0 Goal: $12,000
0% of monthly goal Help us cross the finish line!
Sponsor DDEV

add-on registry tests last commit release

DDEV Site Metrics

Overview

This addon contains tools for using OpenTelemetry with a DDEV project.

It contains the following packages:

Installation

To install this add-on, run:

ddev add-on get tyler36/ddev-site-metrics
ddev restart

After installation, make sure to commit the .ddev directory to version control.

Ports

Port Service UI Environment variable
3000 Grafana GRAFANA_HTTPS_PORT
3100 Grafana Loki  
3200, 3300,4317 4318 Grafana Tempo  
9090 Prometheus PROMETHEUS_HTTPS_PORT
9100 Node Exporter NODE_EXPORTER_HTTP_PORT
9104 MySQL Exporter  
9113 Nginx Exporter  
9117 Apache Exporter  
9187 Postgres Exporter  
4317 4318, 12345 Grafana Alloy ✅ (12345)  

Tools

Grafana

Grafana is a tool to “Query, visualize, alert on, and explore your metrics, logs, and traces wherever they are stored.”.

Configure Datasources

This addon pre-configures Prometheus as a datasource.

See Grafana data sources.

Configure Dashboards

This add-on pre-configures .ddev/grafana/provisioning/dashboards as the provisioned dashboard folder. See Dashboards. See Dashboard JSON model.

Configure plugins

To install a plugin, create or update .ddev/docker-compose.grafana_custom.yaml. Replace <plugin-id> with the plugin ID.

services:
  grafana:
    environment:
      - GF_PLUGINS_PREINSTALL=<plugin-id>

To find the plugin ID:

Grafana Alloy

Grafana Alloy can collect, process, and export telemetry signals to scale and future-proof your observability approach.

This addon configures Grafana Alloy to collect and process:

To configure Grafana Alloy, add/update files in .ddev/alloy. By default, all files in this directory are loaded and processed.

Usage

Grafana Alloy runs within the process on its default port of 12345.

ddev alloy
ddev alloy -r

Grafana Loki

Grafana Loki is a set of open source components that can be composed into a fully featured logging stack.

Grafana Loki listens on its default port of 3100. To view processed logs, visit Drilldown | Logs in the Grafana dashboard.

ddev launch :3000/a/grafana-lokiexplore-app/explore

Key files include:

Key files include:

Grafana Tempo

Grafana Tempo is an open-source, easy-to-use, and high-scale distributed tracing backend.

In this add-on, Grafana Alloy forwards open telemetry data it receives to Grafana Tempo for processing (./alloy/otelcol.alloy). Grafana Tempo datasource is pre-configured in Grafana allowing a centralized location for interacting with traces.

OTEL_SERVICE_NAME="tempo"
OTEL_EXPORTER_OTLP_ENDPOINT="http://grafana-alloy:4318"

Prometheus

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud.

Prometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.

To open Prometheus: ddev prometheus or ddev launch :9090 (assuming the default port).

Customize Prometheus

Prometheus is configured via ./.ddev/prometheus/prometheus.yml. This addon provides an example, but need to customize it for your use-case.

Prometheus’s main configuration is in .ddev/prometheus/prometheus.yml. To customize, take ownership by removing #ddev-generated and making the changes as required.

Developers can add scrape_confi details to this file, as shown below.

global:
  scrape_interval: 5s  # How often Prometheus scrapes data

scrape_configs:
  - job_name: 'web'
    metrics_path: '/metrics'
    static_configs:
      - targets: ['web'] # Change to your app's hostname and port. Here, we use DDEV web container.

However, this Prometheus will try to load .ddev/prometheus/scrape-*.yml files. Inversely, removing one of these scrap files will disable it. View .ddev/prometheus/scrape-*.yml for more information.

PROMETHEUS_HTTPS_PORT=9090

Addon: Apache Exporter

The Apache Exporter uses lusotycoon/apache-exporter to monitor the apache webs service.

This addon pre-configures the Apache exporter for a DDEV environment.

Key files include:

To expose the status page:

# .ddev/config.webserver.yaml
web_extra_exposed_ports:
  - name: webserver
    container_port: 8080
    http_port: 8081
    https_port: 8080

The included dashboard is extended from apache-http-mixin.

Addon: Nginx Exporter

The Nginx Exporter uses NGINX Prometheus exporter to monitor NGINX or NGINX Plus using Prometheus.

This addon pre-configures the Nginx Prometheus exporter for a DDEV environment In additional, an example dashboard is available in Grafana.

Key files include:

Addon: MySql Exporter

MySql Exporter exports MySQL server metrics into Prometheus. The metrics can be used in Grafana:

This addon includes an example dashboard inspired by MySQL Overview.

To use, ensure the .ddev/prometheus/prometheus.yml file scrapes the endpoint:

scrape_configs:
  ...
  # Get exposed MySQL metrics
  - job_name: mysql
    metrics_path: /probe
    params:
      # Not required. Will match value to child in config file. Default value is `client`.
      auth_module: [client.servers]
    static_configs:
      - targets:
        # All mysql hostnames or unix sockets to monitor.
        - db:3306
        # Uncomment to target unix sockets.
        # - unix:///run/mysqld/mysqld.sock
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        # The mysqld_exporter host:port
        replacement: mysql-exporter:9104

Addon: Postgres Exporter

Postgres-exporter exposes PostgreSQL server metrics to Prometheus.

To use, ensure the .ddev/prometheus/prometheus.yml file scrapes the endpoint:

scrape_configs:
  ...
  # Get exposed Postgres metrics
  - job_name: 'postgres'
    static_configs:
      - targets: ['postgres-exporter:9187']

Key files include:

Exposed metrics use the following prefixes: pg and postgres.

Addon: node-exporter

Node Exporter is a Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors.

To use, ensure the .ddev/prometheus/prometheus.yml file scrapes the endpoint:

scrape_configs:
  ...
  - job_name: 'node-exporter'
    static_configs:
      - targets: ['node-exporter:9100']

By default, node-exporter is accessible via node-exporter:9100 inside the docker container. To change the port,

This addon includes an example node dashboard based on Node Exporter Full (v40).

Credits

PRs for install steps for specific frameworks are welcome.

Contributed and maintained by @tyler36