diff --git a/charts/mgmt-agent/README.md b/charts/mgmt-agent/README.md index a34471a..5871a09 100644 --- a/charts/mgmt-agent/README.md +++ b/charts/mgmt-agent/README.md @@ -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//proxy/metrics) metrics to be collected | | kubernetesCluster.overrideAllowMetricsNode | string | `nil` | Provide the specific list of comma separated metric names for Node (/api/v1/nodes//proxy/metrics/resource, /api/v1/nodes//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 | diff --git a/charts/mgmt-agent/resources/auto_prometheus_collection_readme.md b/charts/mgmt-agent/resources/auto_prometheus_collection_readme.md new file mode 100644 index 0000000..e96fd0a --- /dev/null +++ b/charts/mgmt-agent/resources/auto_prometheus_collection_readme.md @@ -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`.
+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.
+The pod's ports specification configuration can be modified using the standardized prometheus.io annotations.
+ +### 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`.
+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.
+Json takes highest precedence and overrides other types (annotation and out of the box)
+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 | diff --git a/charts/mgmt-agent/resources/prometheus-scrape-config.json b/charts/mgmt-agent/resources/prometheus-scrape-config.json new file mode 100644 index 0000000..32960f8 --- /dev/null +++ b/charts/mgmt-agent/resources/prometheus-scrape-config.json @@ -0,0 +1,2 @@ +[ +] \ No newline at end of file diff --git a/charts/mgmt-agent/templates/env-configmap.yaml b/charts/mgmt-agent/templates/env-configmap.yaml index a0a6c0b..97ed6db 100644 --- a/charts/mgmt-agent/templates/env-configmap.yaml +++ b/charts/mgmt-agent/templates/env-configmap.yaml @@ -15,3 +15,4 @@ data: {{- if .Values.deployment.cleanupEpochTime }} POD_CLEANUP_ID: "{{ .Values.deployment.cleanupEpochTime }}" {{- end }} + ENABLE_AUTOMATIC_PROMETHEUS_DETECTION: "{{ .Values.kubernetesCluster.enableAutomaticPrometheusDetection }}" diff --git a/charts/mgmt-agent/templates/metrics-configmap.yaml b/charts/mgmt-agent/templates/metrics-configmap.yaml index c09296b..06d6e25 100644 --- a/charts/mgmt-agent/templates/metrics-configmap.yaml +++ b/charts/mgmt-agent/templates/metrics-configmap.yaml @@ -34,3 +34,5 @@ data: # list of comma separated metric names for Node (/api/v1/nodes//proxy/metrics/resource, /api/v1/nodes//proxy/metrics/cadvisor) metrics overrideAllowMetricsNode={{ .Values.kubernetesCluster.overrideAllowMetricsNode }} {{- end }} + prometheus-scrape-config.json: | +{{ .Files.Get "resources/prometheus-scrape-config.json" | indent 4 }} diff --git a/charts/mgmt-agent/values.schema.json b/charts/mgmt-agent/values.schema.json index 2c614ee..bec0244 100644 --- a/charts/mgmt-agent/values.schema.json +++ b/charts/mgmt-agent/values.schema.json @@ -131,11 +131,16 @@ "type": "null" } ] + }, + "enableAutomaticPrometheusDetection": + { + "type": "boolean" } }, "required": [ - "namespace" + "namespace", + "enableAutomaticPrometheusDetection" ] }, "deployment": diff --git a/charts/mgmt-agent/values.yaml b/charts/mgmt-agent/values.yaml index 0ac47f8..3975f31 100644 --- a/charts/mgmt-agent/values.yaml +++ b/charts/mgmt-agent/values.yaml @@ -67,6 +67,9 @@ kubernetesCluster: overrideAllowMetricsKubelet: # -- Provide the specific list of comma separated metric names for Node (/api/v1/nodes//proxy/metrics/resource, /api/v1/nodes//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: diff --git a/charts/oci-onm/values.yaml b/charts/oci-onm/values.yaml index 4272bf1..74194e4 100644 --- a/charts/oci-onm/values.yaml +++ b/charts/oci-onm/values.yaml @@ -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: