> For the complete documentation index, see [llms.txt](https://docs.akamas.io/insights/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akamas.io/insights/connecting-your-data/datasources/prometheus.md). Agents can also search and read this documentation through its [MCP server](https://docs.akamas.io/insights/~gitbook/mcp).

# Prometheus and Amazon Managed Prometheus

Akamas Vivo supports multiple Prometheus-compatible data sources, including standard **Prometheus**, **Thanos**, and **Amazon Managed Prometheus** (AMP). This page covers configuration for self-hosted Prometheus and AWS-managed deployments. For Grafana Cloud's Prometheus implementation, see the [Grafana Cloud configuration page](https://docs.akamas.io/insights/connecting-your-data/datasources/grafana-cloud.md).

## Metric Sources & Prerequisites

Akamas Vivo collects Kubernetes and application runtime metrics from your Prometheus-compatible endpoint. Before connecting your data source, ensure the following components are deployed and configured in your cluster. Two setup configurations are supported: the **Kubernetes Monitoring Stack** and **OpenTelemetry Kubernetes Metrics**.

### Kubernetes Monitoring Stack

The simplest way to ensure all required metrics are available is to deploy the [kube-prometheus-stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) Helm chart. It bundles all the necessary components:

* [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics): Kubernetes object state metrics.
* Kubernetes recording rules from the [kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin) project.
* The kubelet and [cAdvisor](https://github.com/google/cadvisor) endpoints (`/metrics` and `/metrics/cadvisor`), scraped by default. cAdvisor provides the `container_*` series (CPU and memory usage, throttling, OOM events) and is required in every setup. With a standalone Prometheus, add scrape jobs for both kubelet endpoints.

The chart also installs the [Prometheus node exporter](https://github.com/prometheus/node_exporter), which Akamas Vivo does not use. It can stay in place.

{% hint style="warning" %}
**Recording rules are required in the Kubernetes Monitoring Stack setup.** Akamas Vivo depends on pre-computed Prometheus recording rules provided by the kubernetes-mixin. These rules are automatically included in kube-prometheus-stack, but they are **not** available in standalone Prometheus or Mimir deployments unless explicitly configured.

Without these recording rules, the data import will fail to discover and extract workload, pod, and node metrics. OpenTelemetry setups need only one of these rules, see [OpenTelemetry Kubernetes Metrics](#opentelemetry-kubernetes-metrics).
{% endhint %}

**Node Labels for Cluster Autoscaler Recommendations**

To provide optimization recommendations for Cluster Autoscaler node groups, Akamas Vivo needs access to Kubernetes node labels. It reads the instance type (`node.kubernetes.io/instance-type`), the region (`topology.kubernetes.io/region`, or the OpenTelemetry `cloud_region` on nodes without it), the node pool (for example `agentpool`, the EKS node group, the GKE node pool or the Karpenter node pool) and the node role labels (`node-role.kubernetes.io/control-plane`, `node-role.kubernetes.io/master`, `node-role.kubernetes.io/infra`, `node-role.kubernetes.io/etcd`).

By default, kube-state-metrics does not expose all labels on the `kube_node_labels` metric. You must explicitly allow them using the `metricLabelsAllowlist` setting:

**Helm values (`values.yaml`):**

```yaml
kube-state-metrics:
  metricLabelsAllowlist:
    - nodes=[*]
```

Or, if deploying kube-state-metrics standalone:

```yaml
metricLabelsAllowlist:
  - nodes=[*]
```

{% hint style="info" %}
Without this configuration, Akamas Vivo will still collect and optimize workload metrics, but Cluster Autoscaler node group recommendations will not be available.
{% endhint %}

### OpenTelemetry Kubernetes Metrics

If your environment uses the [OpenTelemetry (OTel) Collector](https://opentelemetry.io/docs/collector/) for Kubernetes metrics, Akamas Vivo can read the OTel `k8s_*` metrics in place of the kube-state-metrics ones.

{% hint style="warning" %}
**OTel setups still need one recording rule and cAdvisor.**

* The rule is `namespace_workload_pod:kube_pod_owner:relabel` from the kubernetes-mixin, which maps every pod to its workload. It is computed from the kube-state-metrics series `kube_pod_owner`, `kube_replicaset_owner` and `kube_job_owner`, so those series and the rule must be available. Without it, workloads cannot be identified.
* CPU and memory usage, throttling and OOM events come from cAdvisor (`container_*` series from the kubelet `/metrics/cadvisor` endpoint), not from the OTel kubelet metrics. Scrape it with Prometheus (or an equivalent agent) alongside the collector.

Akamas Vivo reads the OTel metrics only when the kube-state-metrics series `kube_pod_info` is absent for the cluster. When `kube_pod_info` is present, the Kubernetes Monitoring Stack setup is used and all of its requirements apply.
{% endhint %}

The following OpenTelemetry Collector components are required:

| Component                                                                                                                                | Purpose                                                                                                                                                                 |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [k8s Cluster Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver)          | Node, pod, container, and workload metrics (`k8s_node_info`, `k8s_pod_info`, `k8s_pod_phase`, `k8s_container_cpu_request`, `k8s_deployment_desired`, `k8s_hpa_*`, etc.) |
| [Kubelet Stats Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kubeletstatsreceiver)      | Node usage metrics (`k8s_node_cpu_usage`), which carry the node labels used for node groups                                                                             |
| [K8s Attributes Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/k8sattributesprocessor) | Enriches metrics with workload labels (`deployment`, `statefulset`, `daemonset`, `job_name`)                                                                            |

The k8s Cluster Receiver emits `k8s_node_allocatable_cpu` and `k8s_node_allocatable_memory_bytes` only when `allocatable_types_to_report: [cpu, memory]` is set, as in the example below.

**Example OTel Collector configuration:**

```yaml
receivers:
  k8s_cluster:
    collection_interval: 30s
    auth_type: serviceAccount
    allocatable_types_to_report: [cpu, memory]
  kubeletstats:
    collection_interval: 30s
    auth_type: serviceAccount
    endpoint: "https://${env:K8S_NODE_NAME}:10250"
    insecure_skip_verify: true

processors:
  k8sattributes:
    auth_type: serviceAccount
    extract:
      metadata:
        - k8s.deployment.name
        - k8s.statefulset.name
        - k8s.daemonset.name
        - k8s.job.name
        - k8s.cronjob.name

exporters:
  prometheusremotewrite:
    endpoint: "http://your-prometheus-endpoint/api/v1/write"

service:
  pipelines:
    metrics:
      receivers: [k8s_cluster, kubeletstats]
      processors: [k8sattributes]
      exporters: [prometheusremotewrite]
```

**Node labels.** On Azure AKS clusters, Akamas Vivo reads the instance type from the `azure_vm_size` label and derives the node pool from `azure_vm_name` or `host_name` (`aks-<pool>-...`). These labels must be present on `k8s_node_info` or `k8s_node_cpu_usage`.

### Required Kubernetes Metrics

Check the cAdvisor list and the table for your setup. Series carry the `namespace`, `pod` and `container` labels that apply to their level; cAdvisor series and `kube_pod_container_resource_*` also need `node`. When you import clusters by label, every series must also carry that label (`cluster` by default). Series marked *optional* are only used for charts.

#### Both setups: cAdvisor

`container_cpu_usage_seconds_total`, `container_memory_rss`, `container_memory_working_set_bytes`, `container_cpu_cfs_throttled_seconds_total`, `container_cpu_cfs_throttled_periods_total`, `container_cpu_cfs_periods_total`, `container_oom_events_total`

#### Kubernetes Monitoring Stack

| Layer             | kube-state-metrics and kubelet                                                                                                                                                                                                                                                                             | Recording rules                                                                                                                                                                                                                                                                                      |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cluster           | `kube_node_status_allocatable` (`resource` = `cpu`, `memory`)                                                                                                                                                                                                                                              | `namespace_cpu:kube_pod_container_resource_requests:sum`, `namespace_memory:kube_pod_container_resource_requests:sum`; *optional*: `namespace_cpu:kube_pod_container_resource_limits:sum`, `namespace_memory:kube_pod_container_resource_limits:sum`                                                 |
| Node              | `kube_node_status_allocatable`, `kubelet_running_pods`, `kube_node_labels` (node group recommendations, with the allowlist above)                                                                                                                                                                          | `cluster:namespace:pod_cpu:active:kube_pod_container_resource_requests`, `cluster:namespace:pod_memory:active:kube_pod_container_resource_requests`                                                                                                                                                  |
| Workload          | `kube_pod_container_resource_requests`, `kube_pod_container_resource_limits`, `kube_pod_status_phase`, `kube_job_owner`                                                                                                                                                                                    | `namespace_workload_pod:kube_pod_owner:relabel`                                                                                                                                                                                                                                                      |
| HPA               | `kube_horizontalpodautoscaler_info`, `kube_horizontalpodautoscaler_spec_min_replicas`, `kube_horizontalpodautoscaler_spec_max_replicas`, `kube_horizontalpodautoscaler_status_desired_replicas`, `kube_horizontalpodautoscaler_status_current_replicas`, `kube_horizontalpodautoscaler_spec_target_metric` |                                                                                                                                                                                                                                                                                                      |
| Pod and Container | `kube_pod_info`, `kube_pod_container_resource_requests`, `kube_pod_container_resource_limits`                                                                                                                                                                                                              | `cluster:namespace:pod_cpu:active:kube_pod_container_resource_requests`, `cluster:namespace:pod_memory:active:kube_pod_container_resource_requests`, `cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits`, `cluster:namespace:pod_memory:active:kube_pod_container_resource_limits` |

#### OpenTelemetry Kubernetes Metrics

| Layer             | Metrics                                                                                                                                                                                                                                                                                                                                                        |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cluster           | `k8s_container_cpu_request`, `k8s_container_memory_request_bytes`, `k8s_node_allocatable_cpu`, `k8s_node_allocatable_memory_bytes`, `k8s_pod_phase`; *optional*: `k8s_container_cpu_limit`, `k8s_container_memory_limit_bytes`                                                                                                                                 |
| Node              | `k8s_node_info`, `k8s_node_cpu_usage`, `k8s_node_allocatable_cpu`, `k8s_node_allocatable_memory_bytes`, `k8s_container_cpu_request`, `k8s_container_memory_request_bytes`, `k8s_pod_phase`                                                                                                                                                                     |
| Workload          | `k8s_pod_info`, `k8s_container_cpu_request`, `k8s_container_cpu_limit`, `k8s_container_memory_request_bytes`, `k8s_container_memory_limit_bytes`, `k8s_deployment_desired`, `k8s_statefulset_desired_pods`, `k8s_daemonset_desired_scheduled_nodes`, `k8s_job_desired_successful_pods`, and the recording rule `namespace_workload_pod:kube_pod_owner:relabel` |
| HPA               | `k8s_hpa_min_replicas`, `k8s_hpa_max_replicas`, `k8s_hpa_desired_replicas`, `k8s_hpa_current_replicas`                                                                                                                                                                                                                                                         |
| Pod and Container | `k8s_pod_info`, `k8s_pod_phase`, `k8s_container_cpu_request`, `k8s_container_cpu_limit`, `k8s_container_memory_request_bytes`, `k8s_container_memory_limit_bytes`                                                                                                                                                                                              |

If any of the cluster or node capacity series is missing, the cluster capacity charts stay empty.

{% hint style="info" %}
**HPA scaling targets.** Akamas Vivo reads the CPU or memory target of an HPA from `kube_horizontalpodautoscaler_spec_target_metric`. Without it, HPA recommendations are best-effort, sized from observed CPU demand, and some workloads may get none. This is the case:

* in OpenTelemetry setups, which have no equivalent metric;
* for an HPA that defines no CPU or memory target.

OTel HPA metrics cover Deployments and StatefulSets.
{% endhint %}

### Application Runtime Metrics

Beyond Kubernetes infrastructure metrics, Akamas Vivo can analyze application runtime data to provide full-stack optimization recommendations, including JVM heap sizing and Node.js V8 heap configuration, all coordinated with Kubernetes resource limits. This requires your applications to expose runtime metrics via one of the supported exporters.

#### Label Requirements

Runtime metrics must include labels that identify the Kubernetes **node**, **namespace**, **pod**, and **container** where the application runs, plus the cluster label when you import clusters by label. Akamas Vivo uses these labels to correlate runtime metrics with the corresponding Kubernetes resources.

The cluster label is chosen in the data import setup (the **Use cluster labels** option for Prometheus, the **Cluster Label Configuration** section for Amazon Managed Prometheus). The specific label names used by your exporter are also configured during the data import setup (e.g., `node` vs `k8s_node_name`, `pod` vs `k8s_pod_name`).

#### Java

Akamas Vivo supports three Java instrumentation methods. Only one is required per application.

Generation-level heap sizing relies on naming. Old generation pools must contain `Old` or `Tenured` and young generation pools `Eden` or `Survivor`. Young collections are recognized by collector name (`Copy`, `PS Scavenge`, `G1 Young Generation`, `ParNew`) with the JMX Exporter, and by the `end of minor GC` action with Micrometer and the OpenTelemetry agent. Collectors with other names, such as non-generational ZGC, get no generation-level recommendations.

[**Prometheus JMX Exporter**](https://github.com/prometheus/jmx_exporter) - supported: [1.0.1](https://github.com/prometheus/jmx_exporter/releases/tag/1.0.1)+

Required metrics:

* `jvm_memory_used_bytes`, `jvm_memory_committed_bytes`, `jvm_memory_max_bytes` - labels: `area`
* `jvm_memory_pool_used_bytes`, `jvm_memory_pool_committed_bytes` - labels: `pool`
* `jvm_gc_collection_seconds_sum` - labels: `gc`

Optional metrics (charts only):

* `jvm_memory_pool_max_bytes` - labels: `pool`
* `jvm_gc_collection_seconds_count` - labels: `gc`

[**Micrometer / Spring Boot Actuator**](https://micrometer.io/) - supported: [Micrometer 1.14](https://github.com/micrometer-metrics/micrometer/releases/tag/v1.14.0)+ / [Spring Boot 3.4](https://github.com/spring-projects/spring-boot/releases/tag/v3.4.0)+

Required metrics:

* `jvm_memory_used_bytes`, `jvm_memory_committed_bytes`, `jvm_memory_max_bytes` - labels: `area`, `id`
* `jvm_gc_pause_seconds_sum` - labels: `action`, `cause`, `gc`

Optional metrics:

* `jvm_gc_concurrent_phase_time_seconds_sum` - labels: `cause` (added to the GC time when present)
* `jvm_gc_pause_seconds_count`, `jvm_gc_concurrent_phase_time_seconds_count` (charts only)

[**OpenTelemetry Java Agent**](https://opentelemetry.io/docs/languages/java/) - supported: [2.25.0](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v2.25.0)+

Required metrics:

* `jvm_memory_used_bytes`, `jvm_memory_committed_bytes`, `jvm_memory_limit_bytes` - labels: `jvm_memory_type`, `jvm_memory_pool_name`
* `jvm_gc_duration_seconds_sum` - labels: `jvm_gc_action`, `jvm_gc_name`

Optional metrics (charts only):

* `jvm_gc_duration_seconds_count`

#### Node.js

[**OpenTelemetry Node.js SDK**](https://opentelemetry.io/docs/languages/js/) - supported: [@opentelemetry/instrumentation-runtime-node 0.22.0](https://www.npmjs.com/package/@opentelemetry/instrumentation-runtime-node)+

Required metrics:

* `v8js_memory_heap_used_bytes`, `v8js_memory_heap_space_physical_size_bytes`, `v8js_memory_heap_space_size_bytes` - labels: `v8js_heap_space_name`

Recommended metrics:

* `v8js_memory_heap_limit_bytes`

Optional metrics:

* `nodejs_eventloop_utilization_ratio` - used for findings
* `v8js_gc_duration_seconds_sum`, `v8js_gc_duration_seconds_count` - labels: `v8js_gc_type` (charts only)

## Default Prometheus

[Prometheus](https://prometheus.io/) is an open-source monitoring and alerting toolkit designed for reliability and scalability in cloud-native environments.

### Requirements

Before connecting Prometheus to Akamas Vivo, ensure you have the followings.

#### Required Information

* **Endpoint URL**: The HTTP endpoint of your Prometheus server (e.g., `http://prometheus-server:9090`).
* **Custom Headers** (optional): Additional HTTP headers for authentication or routing.

#### Authentication Options

Akamas Vivo supports Prometheus instances with and without authentication:

* **No Authentication**: Default Prometheus installations without security enabled.
* **Custom Headers**: For authenticated Prometheus variants like Thanos, you can configure custom HTTP headers:
  * **Bearer Token Authentication**: Add `Authorization: Bearer <token>` header.
  * **Basic Authentication**: Add `Authorization: Basic <base64-credentials>` header.
  * **API Key Headers**: Add custom headers like `X-API-Key: <key>` if required by your setup.
  * **Proxy Headers**: Add routing or identification headers required by reverse proxies.

{% hint style="info" %}
For Grafana Cloud Prometheus, use the dedicated [Grafana Cloud configuration](https://docs.akamas.io/insights/connecting-your-data/datasources/grafana-cloud.md) which handles authentication automatically.
{% endhint %}

#### Network Access

* **Network connectivity** from Akamas Vivo to your Prometheus endpoint.
* **Firewall** rules allowing HTTP/HTTPS traffic to the Prometheus API.

{% hint style="info" %}
You can obtain this information from the following references:

* [Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/)
* [Prometheus Configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/)
  {% endhint %}

### Configuration

To connect to a Prometheus instance:

1. **Provide the required credentials** (see above).
2. **Save** the integration once validated.
3. **Test Connection** to verify the configuration.

## Amazon Managed Prometheus (AMP)

[Amazon Managed Prometheus](https://aws.amazon.com/prometheus/) is a fully managed Prometheus-compatible monitoring service that provides secure, scalable metrics storage and querying for container workloads.

### Requirements

Before connecting Amazon Managed Prometheus to Akamas Vivo, ensure you have the followings.

#### Required Credentials

* **Endpoint URL**: Your AMP workspace query endpoint in the format `https://aps-workspaces.{region}.amazonaws.com/workspaces/{workspace-id}/` .
* **AWS Access Key**: IAM access key ID with AMP read permissions.
* **AWS Secret Key**: Corresponding IAM secret access key.
* **AWS Region**: The AWS region where your AMP workspace is deployed (e.g., `us-east-1`).

#### Required IAM Permissions

Your IAM credentials must have the following permissions:

* `aps:QueryMetrics`: Query metrics from the AMP workspace.
* `aps:GetMetricMetadata`: Retrieve metadata about available metrics.

{% hint style="info" %}
You can obtain this information from the following references:

* [AWS AMP IAM Permissions](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-and-IAM.html)
* [AWS AMP Query API](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-query.html)
  {% endhint %}

### Configuration

To connect to Amazon Managed Prometheus:

1. **Provide the required credentials** (see above).
2. **Save** the integration once validated.
3. **Test Connection** to verify the configuration.

## Advanced Options

These advanced settings allow you to tune the data extraction process for Prometheus-compatible data sources to optimize performance and manage query load. In most cases, the default values work well, but you can adjust them based on your environment size and query performance.

When your imports run through the managed extraction pipeline, a single tuning option is available:

* **Concurrency**: Maximum number of concurrent queries the import sends to your Prometheus endpoint (default: 20; selectable values: 5, 10, then 20 to 100 in steps of 10). Raise it for a faster import if your endpoint can absorb the extra query load; values above 20 show a warning because they may trigger rate limiting or degrade the monitoring backend while the import runs.

#### Legacy Advanced Options

Imports running through the legacy pipeline expose the following options instead:

* **Retries**: Number of retry attempts for failed Prometheus queries (default: 1). Increase this value if you experience intermittent connectivity issues or timeout errors. Higher values increase resilience but may slow down extraction when encountering persistent failures;
* **Parallelism**: Number of concurrent worker threads for parallel query execution (default: 5). Increase for faster extraction if your Prometheus instance can handle higher query rates, or decrease to reduce load on the server;
* **Batch Size**: Number of entities to batch in a single Prometheus query (default: 20). Determines how many pods, containers, or other entities are included in a single query. Increase to reduce total number of queries (faster extraction), or decrease to reduce individual query complexity and memory usage.
