|
| 1 | +# 1. Introduction |
| 2 | +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. |
| 3 | + |
| 4 | +# 2. Identification of metric collection configuration |
| 5 | + |
| 6 | +## 2.1 Out of the box |
| 7 | +Management Agent has capabilities to detect metrics emitting pods, without making any custom configuration changes. |
| 8 | + |
| 9 | +### 2.1.1 Pod' ports specification |
| 10 | +Management Agent will look for pod port spec with port name as `metrics` and port protocol as `TCP`.</br> |
| 11 | +Once found, the configuration is build using default path as `/metrics`. The rest of the configuration is set to default as well. |
| 12 | + |
| 13 | +### 2.1.2 Prometheus.io Annotation |
| 14 | +Deployments using industry standard prometheus.io annotations to enable scrapping, will be automatically detected out of the box by agent.</br> |
| 15 | +The pod's ports specification configuration can be modified using the standardized prometheus.io annotations.</br> |
| 16 | + |
| 17 | +### Sample annotation |
| 18 | +``` |
| 19 | + annotations: |
| 20 | + prometheus.io/path: "/path/to/metrics" |
| 21 | + prometheus.io/port: "8080" |
| 22 | + prometheus.io/scrape: "true" |
| 23 | +``` |
| 24 | +Agent will only scrape if `prometheus.io/scrape` is set to `true`.</br> |
| 25 | +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. |
| 26 | + |
| 27 | +## 2.2. prometheus scrape config json |
| 28 | +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> |
| 29 | +Json takes highest precedence and overrides other types (annotation and out of the box)</br> |
| 30 | +If a pod matches multiple configs, then the last matching config will be applied. |
| 31 | + |
| 32 | +### 2.2.1 Sample JSON with all supported parameters (including optional) |
| 33 | +``` |
| 34 | +[ |
| 35 | + { |
| 36 | + "podMatcher": |
| 37 | + { |
| 38 | + "namespaceRegex": "pod_namespace.*", |
| 39 | + "podNameRegex": "sample-pod.*" |
| 40 | + }, |
| 41 | + "config": |
| 42 | + { |
| 43 | + "path": "/path/to/metrics/endpoint", |
| 44 | + "port": 9100, |
| 45 | + "namespace": "push_metrics_to_namespace", |
| 46 | + "allowMetrics": "sampleMetric1,sampleMetric2", |
| 47 | + "compartmentId": "ocid1.compartment.oc1..sample", |
| 48 | + "scheduleMins": 1 |
| 49 | + }, |
| 50 | + "disable": false |
| 51 | + }, |
| 52 | + ... |
| 53 | +] |
| 54 | +``` |
| 55 | + |
| 56 | +### 2.2.2 First class members |
| 57 | +| member | required | description | |
| 58 | +|--------|----------|-------------| |
| 59 | +| podMatcher | yes | Elements used to match pods | |
| 60 | +| config | no | Collection configuration for PrometheusEmitter data source of the matching pod. This is optional, if disable is set to `true` | |
| 61 | +| 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 | |
| 62 | + |
| 63 | +### 2.2.3 podMatcher |
| 64 | +| member | required | type | description | |
| 65 | +|--------|----------|----- | ------------| |
| 66 | +| namespaceRegex | yes | `string` | Complete regular expression to match pod's namespace | |
| 67 | +| podNameRegex | yes | `string` | Complete regular expression to match pod's name | |
| 68 | + |
| 69 | +### 2.2.4 config |
| 70 | +| member | required | type | default | description | |
| 71 | +|--------|----------|----- | ------- | ----------- | |
| 72 | +| path | no | `string` | /metrics | Path on which metrics are being emitted, e.g. /metrics | |
| 73 | +| port | yes | `int` | NA | Port on which metrics are being emitted | |
| 74 | +| namespace | no | `string` | pod_prometheus_emitters | OCI namespace to which metrics are pushed | |
| 75 | +| allowMetrics | no | `string` | * | Comma separated metrics allowed to be collected. Defaults to *, which means all | |
| 76 | +| 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 | |
| 77 | +| scheduleMins | no | `int` | 1 | Minute interval at which metrics are collected | |
0 commit comments