Scraping Metrics in Kubernetes

Automatically scrape metrics from pods and other services

Scraping Pods using Prometheus Annotations

groundcover supports standard Prometheus annotations instructing scrapers to periodically fetch metrics from pods.

Once enabled groundcover will automatically discover every pod with those annotations and periodically scrape the metrics path specified.

Annotating Your Pods

Add the following annotations to your Kubernetes pods exposing Prometheus metrics

circle-exclamation
annotations:
  prometheus.io/scrape: "true"
  prometheus.io/port: "<port>"
  prometheus.io/path: "<metrics-path>" # Optional, defaults to /metrics

Scraping from the groundcover Sensor

circle-exclamation

In this configuration, each Sensor scrapes metrics locally from its own node. This reduces overall load and minimizes cross-availability-zone traffic.

agent:
  sensor:
    receivers:
      metricsscraper: 
        enabled: true
custom-metrics:
  scrape_jobs: null

Scraping from the sensors while keeping extraScrapeConfigs on the custom-metrics agent

circle-info

Below is only relevant for setups where custom-metrics is used with additional scrape jobs.

Scraping Prometheus CRDs

groundcover supports scraping Prometheus metrics based on CRDs like PodMonitor and ServiceMonitor. This is achieved using the VictoriaMetrics Operator.

Enable VictoriaMetrics Operator

Deploy the victoria-metrics-operator before enabling the built-in vmagent.

circle-exclamation

Step 1 - Enable only the operator:

Step 2 - Enable builtinVMAgent with a second deployment:

ArgoCD Integration

If deploying monitoring CRDs via ArgoCD, add this override to prevent sync conflicts:

This instructs the operator to add ArgoCD ignore annotations for Prometheus CRDs.

Deploy Monitoring CRDs

The operator automatically discovers and scrapes any deployed Prometheus CRDs (ServiceMonitor, PodMonitor, PrometheusRule, Probe).

Example - PodMonitor

Create my-test-podmonitor.yaml:

Apply it:

The vmagent will automatically reload and begin scraping the new target. Metrics should appear in groundcover’s Grafana dashboard soon after.

VictoriaMetrics Operator also supports its own CRDs; details are available herearrow-up-right.

Setting up Additional Scrape Jobs

groundcover supports setting up additional Prometheus metric scrapingvia a built in vmagentarrow-up-right component (VictoriaMetrics). vmagent supports standard Prometheus scrape job configsarrow-up-right.

The jobs are defined as an array under the custom-metrics section of the helm chart.

Example - Scraping cadvisor metrics

circle-info

By default, only key metrics are collected to limit metric cardinality. Edit the regex to include additional metrics as needed

Example - Scraping Full KSM Metrics

By default, groundcover exports a curated set of kube-state-metrics (KSM) metrics that power native dashboards and screens. These metrics are prefixed with groundcover_ to differentiate them from other KSM deployments.

To collect the complete set of kube-state-metrics (KSM) metrics in groundcover, follow these steps:

  1. Enable all KSM collectors in the ksm deployment.

  2. Enable custom metrics scraping.

  3. Add a scrape job for the KSM metrics.

Metrics Cardinality Limits

groundcover limits the cardinality of the metrics collected from custom jobs.

Defaults:

To raise these limits:

circle-exclamation

Resource Configuration

Defaults:

Common Questions

How often are my metrics scraped?

Metrics are automatically scraped every 10 seconds unless explicitly specified in the scrape job.

Where can I find scraped metrics?

All metrics in the platform can be found in the metrics exploration page: https://app.groundcover.com/explore/data-explorerarrow-up-right

Last updated