Skip to content
GreenKube

Grafana & Prometheus Integration

import { Aside, Steps } from ‘@astrojs/starlight/components’;

GreenKube exposes Prometheus metrics at /prometheus/metrics and ships with a pre-built Grafana dashboard for comprehensive FinGreenOps monitoring.

If you use the kube-prometheus-stack (Prometheus Operator), the Helm chart automatically creates a ServiceMonitor and a NetworkPolicy:

# In your values.yaml
monitoring:
serviceMonitor:
enabled: true # Creates a ServiceMonitor resource
namespace: monitoring # Must match your Prometheus serviceMonitorNamespaceSelector
interval: 30s
networkPolicy:
enabled: true # Allows Prometheus to reach the GreenKube API port
prometheusNamespace: monitoring

If you’re not using the Prometheus Operator, add a scrape config manually:

# Add to your prometheus.yml
scrape_configs:
- job_name: 'greenkube'
scrape_interval: 30s
metrics_path: /prometheus/metrics
static_configs:
- targets: ['greenkube-api.greenkube.svc.cluster.local:8000']

GreenKube exposes the following Prometheus metrics:

MetricTypeDescription
greenkube_co2e_gramsGaugeCO₂e emissions per pod
greenkube_energy_joulesGaugeEnergy consumption per pod
greenkube_cost_totalGaugeCost per pod
greenkube_cpu_usage_millicoresGaugeCPU utilization per pod
greenkube_memory_usage_bytesGaugeMemory usage per pod
greenkube_network_receive_bytesGaugeNetwork bytes received per pod
greenkube_network_transmit_bytesGaugeNetwork bytes transmitted per pod
greenkube_grid_intensityGaugeGrid carbon intensity per zone
greenkube_recommendation_totalGaugeRecommendation counts by type
greenkube_node_infoInfoNode metadata (instance type, zone, capacity)

All metrics include labels for pod, namespace, node, and zone where applicable.

  1. Get the dashboard JSON

    The dashboard file is at dashboards/greenkube-grafana.json in the GreenKube repository.

  2. Import in Grafana

    In Grafana, go to Dashboards → Import, then either:

    • Upload the greenkube-grafana.json file, or
    • Paste the JSON content directly
  3. Select your data source

    Choose the Prometheus data source that scrapes GreenKube metrics.

  4. Click Import

    The dashboard is ready to use immediately.

The pre-built Grafana dashboard includes:

KPI Row:

  • Total CO₂e emissions
  • Total cost
  • Total energy consumption
  • Active pods count
  • Active nodes count

Time-Series Charts:

  • CO₂e emissions over time
  • Cost trends over time
  • Energy consumption over time

Namespace Breakdown:

  • Pie charts for CO₂e distribution by namespace
  • Pie charts for cost distribution by namespace

Top Pods:

  • Bar charts for highest-emitting pods
  • Bar charts for most expensive pods

Node Utilization:

  • CPU usage per node
  • Memory usage per node

Grid Intensity:

  • Carbon intensity over time per zone

Recommendations:

  • Summary table of optimization suggestions with estimated savings

The dashboard is fully customizable in Grafana. Common modifications include:

  • Adjusting time ranges and refresh intervals
  • Adding alerts on CO₂e thresholds
  • Filtering by specific namespaces
  • Adding custom panels using the GreenKube Prometheus metrics