The OpenTelemetry Collector, when configured with a StatsD receiver, provides an integration with Gunicorn to receive StatsD metrics. The Collector uses the StatsD Receiver to receive metrics from the configured endpoint in the Gunicorn configuration file. From there, the metrics are processed and exported to Lightstep Observability.
To complete the integration, you will:
- Configure Gunicorn to use the StatsD endpoint.
- Configure the Collector StatsD endpoint to host for the StatsD receiver.
- Enable the integration by adding it to a pipeline.
Prerequisites
- You have a intermediate understanding of StatsD metrics.
- You’ve configured the Collector to export metric data to Lightstep Observability.
Configure Gunicorn reporting
You need to configure Gunicorn to use the StatsD exporter.
Run your Gunicorn server with --statsd-host
argument like the following example:
1
gunicorn --bind 0.0.0.0:5000 main:app --statsd-host otel-collector:8125
Configure the Collector receiver
Gunicorn emits metrics through custom StatsD format. Emitted metrics are broadcasted from StatsD using UDP on the StatsD default port 8125
.
In the Collector configuration file, configure the StatsD receiver to host StatsD endpoint to receive metrics.
1
2
3
4
5
6
7
8
9
10
receivers:
statsd:
endpoint: "otel-collector:8125"
aggregation_interval: 70s
enable_metric_type: true
is_monotonic_counter: false
timer_histogram_mapping:
- statsd_type: "histogram"
observer_type: "summary"
- statsd_type: "timing"
The OpenTelemetry repo provides additional details about StatsD receiver configuration.
More details about the StatsD configuration can be found here.
Enable the Collector receiver
Once the Gunicorn receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.
Validate metrics are reporting to Lightstep
You can validate that metrics are reporting to Lightstep on the Metrics details page in Project settings.
-
In Lightstep, click Project settings > Metric details.
-
Search for Gunicorn metric names.
-
If needed, click on the metric to edit the description and how the units are displayed in Lightstep.
Create a dashboard for the metrics
Use the Lightstep Terraform Provider to create a dashboard for the metrics.
Additional resources
For a more complete example that’s ready to run, see the Gunicorn integration in Lightstep OpenTelemetry Examples.