Collecting Metrics #
In order to collect metrics from your services, they have to connect to the quantum-custom-metrics network.
Configuration #
The following labels are available:
| label | description | default value | required |
|---|---|---|---|
com.planetary-quantum.metrics.custom | name of the job for querying | yes | |
com.planetary-quantum.metrics.custom.port | port where your server runs | 80 | no |
com.planetary-quantum.metrics.custom.path | metrics route/endpoint | /metrics | no |
Example stack #
To deploy the service and to enable the collecting of metrics, review the following stack (featuring two example services):
appservice:http://tasks.app:8181/metricsbackendservice:http://tasks.backend:80/metriken
version: "3.8"
services:
app:
image: registry.example.org/company/app:1.2.3
deploy:
labels:
com.planetary-quantum.metrics.custom: app
com.planetary-quantum.metrics.custom.port: 8181
networks:
- quantum-custom-metrics
- lan
- public
backend:
image: registry.example.org/company/backend:4.5.6
deploy:
labels:
com.planetary-quantum.metrics.custom: backend
com.planetary-quantum.metrics.custom.path: /metriken
networks:
- lan
- quantum-custom-metrics
networks:
lan:
quantum-custom-metrics:
external: true
public:
external: true
In detail:
- both services connect to the
quantum-custom-metricsnetwork com.planetary-quantum.metrics.customtells the agent to collect metricsappuses a custom port (8181), whilebackenduses the standard port (80)backenduses a custom path where metrics are served (/metriken)
Query #
To query your metrics, you need to setup Grafana and start by querying for your new jobs:
{job=~"app|backend"}
by cluster/environment #
With the CLUSTER= environment variable in our example, we also provide an additional label for these metrics to filter on.
Our example stack used the value of $QUANTUM_ENDPOINT which can be convenient if you run a staging and production cluster to easily filter the metrics in your queries and dashboards. Consider the following example using your own app_requests metric.
app_requests{cluster="my-staging-cluster"}