Skip to content

New feature 'Automatic Prometheus Collection' and upgrade agent image to version 1.8 #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/mgmt-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A Helm chart for collecting Kubernetes Metrics using OCI Management Agent into O
| kubernetesCluster.overrideAllowMetricsCluster | string | `nil` | Provide the specific list of comma separated metric names for agent computed metrics to be collected |
| kubernetesCluster.overrideAllowMetricsKubelet | string | `nil` | Provide the specific list of comma separated metric names for Kubelet (/api/v1/nodes/<node_name>/proxy/metrics) metrics to be collected |
| kubernetesCluster.overrideAllowMetricsNode | string | `nil` | Provide the specific list of comma separated metric names for Node (/api/v1/nodes/<node_name>/proxy/metrics/resource, /api/v1/nodes/<node_name>/proxy/metrics/cadvisor) metrics to be collected |
| kubernetesCluster.enableAutomaticPrometheusDetection | bool | `false` | Setting this to true will enable automatic PrometheusEmitter metrics collection from eligible pods |
| mgmtagent.image.secret | string | `nil` | Image secrets to use for pulling container image (base64 encoded content of ~/.docker/config.json file) |
| mgmtagent.image.url | string | `nil` | Replace this value with actual docker image URL for Management Agent |
| mgmtagent.installKey | string | `"resources/input.rsp"` | Copy the downloaded Management Agent Install Key file under root helm directory as resources/input.rsp |
Expand Down
77 changes: 77 additions & 0 deletions charts/mgmt-agent/resources/auto_prometheus_collection_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 1. Introduction
Automatic Prometheus collection allows the Agent to automatically find and identify metrics emitting pods to monitor, eliminating the need to manually create the Prometheus configuration to collect metrics.

# 2. Identification of metric collection configuration

## 2.1 Out of the box
Management Agent has capabilities to detect metrics emitting pods, without making any custom configuration changes.

### 2.1.1 Pod' ports specification
Management Agent will look for pod port spec with port name as `metrics` and port protocol as `TCP`.</br>
Once found, the configuration is build using default path as `/metrics`. The rest of the configuration is set to default as well.

### 2.1.2 Prometheus.io Annotation
Deployments using industry standard prometheus.io annotations to enable scrapping, will be automatically detected out of the box by agent.</br>
The pod's ports specification configuration can be modified using the standardized prometheus.io annotations.</br>

### Sample annotation
```
annotations:
prometheus.io/path: "/path/to/metrics"
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
```
Agent will only scrape if `prometheus.io/scrape` is set to `true`.</br>
The `prometheus.io/path` is optional, if not set, then it will default to `/metrics`. The rest of the configuration is set to default as well.

## 2.2. prometheus scrape config json
The configuration can be fine tuned by providing custom json in [prometheus-scrape-config.json](./prometheus-scrape-config.json). This exposes all available PrometheusEmitter parameters.</br>
Json takes highest precedence and overrides other types (annotation and out of the box)</br>
If a pod matches multiple configs, then the last matching config will be applied.

### 2.2.1 Sample JSON with all supported parameters (including optional)
```
[
{
"podMatcher":
{
"namespaceRegex": "pod_namespace.*",
"podNameRegex": "sample-pod.*"
},
"config":
{
"path": "/path/to/metrics/endpoint",
"port": 9100,
"namespace": "push_metrics_to_namespace",
"allowMetrics": "sampleMetric1,sampleMetric2",
"compartmentId": "ocid1.compartment.oc1..sample",
"scheduleMins": 1
},
"disable": false
},
...
]
```

### 2.2.2 First class members
| member | required | description |
|--------|----------|-------------|
| podMatcher | yes | Elements used to match pods |
| config | no | Collection configuration for PrometheusEmitter data source of the matching pod. This is optional, if disable is set to `true` |
| disable | no | This is optional and defaults to `false`. If set to `true`, then podMatcher is used to restrict matching pods from collecting PrometheusEmitter metrics |

### 2.2.3 podMatcher
| member | required | type | description |
|--------|----------|----- | ------------|
| namespaceRegex | yes | `string` | Complete regular expression to match pod's namespace |
| podNameRegex | yes | `string` | Complete regular expression to match pod's name |

### 2.2.4 config
| member | required | type | default | description |
|--------|----------|----- | ------- | ----------- |
| path | no | `string` | /metrics | Path on which metrics are being emitted, e.g. /metrics |
| port | yes | `int` | NA | Port on which metrics are being emitted |
| namespace | no | `string` | pod_prometheus_emitters | OCI namespace to which metrics are pushed |
| allowMetrics | no | `string` | * | Comma separated metrics allowed to be collected. Defaults to *, which means all |
| compartmentId | no | `string` | Agent's compartmentId | Compartment to which metrics are pushed. If not provided, then metrics will be pushed to same compartment where agent is installed |
| scheduleMins | no | `int` | 1 | Minute interval at which metrics are collected |
2 changes: 2 additions & 0 deletions charts/mgmt-agent/resources/prometheus-scrape-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
1 change: 1 addition & 0 deletions charts/mgmt-agent/templates/env-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ data:
{{- if .Values.deployment.cleanupEpochTime }}
POD_CLEANUP_ID: "{{ .Values.deployment.cleanupEpochTime }}"
{{- end }}
ENABLE_AUTOMATIC_PROMETHEUS_DETECTION: "{{ .Values.kubernetesCluster.enableAutomaticPrometheusDetection }}"
2 changes: 2 additions & 0 deletions charts/mgmt-agent/templates/metrics-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ data:
# list of comma separated metric names for Node (/api/v1/nodes/<node_name>/proxy/metrics/resource, /api/v1/nodes/<node_name>/proxy/metrics/cadvisor) metrics
overrideAllowMetricsNode={{ .Values.kubernetesCluster.overrideAllowMetricsNode }}
{{- end }}
prometheus-scrape-config.json: |
{{ .Files.Get "resources/prometheus-scrape-config.json" | indent 4 }}
7 changes: 6 additions & 1 deletion charts/mgmt-agent/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,16 @@
"type": "null"
}
]
},
"enableAutomaticPrometheusDetection":
{
"type": "boolean"
}
},
"required":
[
"namespace"
"namespace",
"enableAutomaticPrometheusDetection"
]
},
"deployment":
Expand Down
3 changes: 3 additions & 0 deletions charts/mgmt-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ kubernetesCluster:
overrideAllowMetricsKubelet:
# -- Provide the specific list of comma separated metric names for Node (/api/v1/nodes/<node_name>/proxy/metrics/resource, /api/v1/nodes/<node_name>/proxy/metrics/cadvisor) metrics to be collected.
overrideAllowMetricsNode:
# Setting this to true will automatically enable PrometheusEmitter metrics collection for eligible pods.
# To customize and get more information, refer ./resources/auto_prometheus_collection_readme.md
enableAutomaticPrometheusDetection: false

deployment:
security:
Expand Down
2 changes: 1 addition & 1 deletion charts/oci-onm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ oci-onm-mgmt-agent:
# Follow steps documented at https://github.com/oracle/docker-images/tree/main/OracleManagementAgent to build docker image.
image:
# Replace this value with actual docker image URL for Management Agent
url: container-registry.oracle.com/oci_observability_management/oci-management-agent:1.7.0
url: container-registry.oracle.com/oci_observability_management/oci-management-agent:1.8.0
# Image secrets to use for pulling container image (base64 encoded content of ~/.docker/config.json file)
secret: