Integration Points - Custom Metric Providers in Thanos
Thanos is an open-source CNCF Sandbox project that extends Prometheus for global-scale, highly available monitoring. It is designed as a clustered system with distinct components, including metric sources, stores, and queriers. This document focuses on the integration points that allow Thanos to be extended with custom metric providers.
- Metric Sources
Thanos supports various metric sources, including Prometheus instances, sidecars, and external services. Custom metric providers can be integrated as additional metric sources. To achieve this, you can use the Thanos Sidecar or the Thanos Ruler.
- Thanos Sidecar: The Sidecar is a lightweight component that runs alongside your application and exports metrics to a Prometheus instance or directly to Thanos. To integrate a custom metric provider with Thanos using the Sidecar, you need to implement a scrape configuration for your provider in the Sidecar.
Example:
scrape_configs:
- job_name: 'my-custom-provider'
static_configs:
- targets: ['my-custom-provider-address:port']
For more information, refer to the Thanos Sidecar documentation.
- Thanos Ruler: The Ruler is a component that evaluates rules and triggers alerts based on the metrics it receives. To integrate a custom metric provider with Thanos using the Ruler, you need to configure a rule group that includes the metrics from your provider.
Example:
groups:
- name: example
rules:
- alert: MyCustomProviderAlert
expr: my_custom_metric > 10
for: 1m
annotations:
description: My custom provider metric is too high
For more information, refer to the Thanos Ruler documentation.
- External Services
Thanos can also ingest metrics from external services, such as statsd, collectd, or any other system that supports remote write. To integrate a custom metric provider with Thanos using an external service, you need to configure the remote write settings in your provider and the Thanos components that will receive the metrics.
Example:
remote_write:
- url: "http://thanos-querier:19090/api/v1/receive"
For more information, refer to the Thanos remote write documentation.
- Query API
Thanos provides a Query API that allows you to query metrics from multiple sources. To integrate a custom metric provider with Thanos using the Query API, you need to configure your provider to send metrics to Thanos and use the Query API to retrieve the metrics.
Example:
curl -G 'http://thanos-querier:19090/api/v1/query' --data-urlencode 'query=my_custom_metric'
For more information, refer to the Thanos Query API documentation.
Thanos is an active open-source project with a welcoming community. If you need help integrating your custom metric provider with Thanos, don’t hesitate to reach out to the community through the Slack channel or GitHub issues.