Skip to content

Commit

Permalink
fix(policies): rewrite meshmetric prometheus example and remove exper…
Browse files Browse the repository at this point in the history
…imental from otel config (kumahq#1702)

---------

Signed-off-by: Marcin Skalski <[email protected]>
  • Loading branch information
Automaat authored Apr 3, 2024
1 parent 3282a28 commit 77758a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/_data/docs_nav_kuma_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ items:
- text: Prometheus
url: "/policies/meshmetric/#prometheus"
- text: OpenTelemetry
url: "/policies/meshmetric/#opentelemetry-experimental"
url: "/policies/meshmetric/#opentelemetry"
- text: Examples
url: "/policies/meshmetric/#examples"
- text: MeshProxyPatch
Expand Down
69 changes: 40 additions & 29 deletions app/_src/policies/meshmetric.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,41 @@ We no longer support activeMTLSBackend, if you need to encrypt and authorize the
If you need to run multiple instances of Prometheus and want to target different set of Data Plane Proxies you can do this by using Client ID setting on both `MeshMetric` (`clientId`) and [Prometheus configuration](https://github.com/prometheus/prometheus/pull/13278/files#diff-17f1012e0c2fbd9bcd8dff3c23b18ff4b6676eef3beca6f8a3e72e6a36633334R2233) (`client_id`).

{% warning %}
Support for `clientId` setting is not yet released in Prometheus, it most likely will be released in Prometheus `2.50.0`.
Support for `clientId` was added in Prometheus version `2.50.0`.
{% endwarning %}

Example configurations differentiated by `prometheus` tag:
###### Example Prometheus configuration

Let's assume we have two prometheus deployments `main` and `secondary`. We would like to use each of them to monitor different sets
of data plane proxies, with different tags.

We can start with configuring each Prometheus deployments to use [Kuma SD](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kuma_sd_config).
Prometheus's deployments will be differentiated by `client_id` parameter.

Main Prometheus config:
```yaml
scrape_configs:
- job_name: 'kuma-dataplanes'
# ...
kuma_sd_configs:
- server: http://{{site.mesh_cp_name}}.{{site.mesh_namespace}}:5676
refresh_interval: 60s # different from prometheus-secondary
client_id: "prometheus-main" # Kuma will use this to pick proper data plane proxies
```

Secondary Prometheus config:
```yaml
scrape_configs:
- job_name: 'kuma-dataplanes'
# ...
kuma_sd_configs:
- server: http://{{site.mesh_cp_name}}.{{site.mesh_namespace}}:5676
refresh_interval: 20s # different from prometheus-main
client_id: "prometheus-secondary"
```

Now we can configure first `MeshMetric` policy to pick data plane proxies with tag `prometheus: main` for main Prometheus discovery.
`clientId` in policy should be the same as `client_id` in Prometheus configuration.
{% policy_yaml first %}
```yaml
type: MeshMetric
Expand All @@ -207,17 +237,18 @@ spec:
targetRef:
kind: MeshSubset
tags:
prometheus: "one"
prometheus: "main"
default:
backends:
- type: Prometheus
prometheus:
clientId: "prometheus-one"
clientId: "prometheus-main"
port: 5670
path: /metrics
```
{% endpolicy_yaml %}

And policy for secondary Prometheus deployment that will pick dataplane proxies with tag `prometheus: secondary`.
{% policy_yaml second %}
```yaml
type: MeshMetric
Expand All @@ -227,42 +258,20 @@ spec:
targetRef:
kind: MeshSubset
tags:
prometheus: "two"
prometheus: "secondary"
default:
backends:
- type: Prometheus
prometheus:
clientId: "prometheus-two"
clientId: "prometheus-secondary" # this clientId should be the same as client_id in Prometheus
port: 5670
path: /metrics
```
{% endpolicy_yaml %}

And the Prometheus configurations:

```yaml
scrape_configs:
- job_name: 'kuma-dataplanes'
# ...
kuma_sd_configs:
- server: http://{{site.mesh_cp_name}}.{{site.mesh_namespace}}:5676
refresh_interval: 60s # different from prometheus-two
client_id: "prometheus-one"
```

```yaml
scrape_configs:
- job_name: 'kuma-dataplanes'
# ...
kuma_sd_configs:
- server: http://{{site.mesh_cp_name}}.{{site.mesh_namespace}}:5676
refresh_interval: 20s # different from prometheus-one
client_id: "prometheus-two"
```

{% if_version lte:2.6.x %}
#### OpenTelemetry (experimental)

{% if_version lte:2.6.x %}
```yaml
backends:
- type: OpenTelemetry
Expand All @@ -289,6 +298,8 @@ When you configure application scraping make sure to specify `application.name`
{% endif_version %}

{% if_version gte:2.7.x %}
#### OpenTelemetry

```yaml
backends:
- type: OpenTelemetry
Expand Down

0 comments on commit 77758a1

Please sign in to comment.