Collecting Metrics

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:

  • com.planetary-quantum.metrics.custom (name of the job for querying, required)
  • com.planetary-quantum.metrics.custom.port (port where your server runs, optional)
  • com.planetary-quantum.metrics.custom.path (metrics route, default: /metrics, optional)

Example stack #

To deploy the service and to enable the collecting of metrics, review the following stack (featuring two example services):

  • app service: http://tasks.app:8181/metrics
  • backend service: 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-metrics network
  • com.planetary-quantum.metrics.custom tells the agent to collect metrics
  • app uses a custom port (8181), while backend uses the standard port (80)
  • backend uses 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"}