Skip to content

Commit f15c921

Browse files
authored
Merge pull request #119097 from Sohamdg081992/sohamUpdateMtls
Update Mtls details for customizing config
2 parents 277ba03 + c089656 commit f15c921

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

articles/azure-monitor/containers/prometheus-metrics-scrape-configuration.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Four different configmaps can be configured to provide scrape configuration and
2929
2. [`ama-metrics-prometheus-config`](https://aka.ms/azureprometheus-addon-rs-configmap) (**Recommended**)
3030
This config map can be used to provide Prometheus scrape config for addon replica. Addon runs a singleton replica, and any cluster level services can be discovered and scraped by providing scrape jobs in this configmap. You can take the sample configmap from the above git hub repo, add scrape jobs that you would need and apply/deploy the config map to `kube-system` namespace for your cluster.
3131
3. [`ama-metrics-prometheus-config-node`](https://aka.ms/azureprometheus-addon-ds-configmap) (**Advanced**)
32-
This config map can be used to provide Prometheus scrape config for addon DaemonSet that runs on every **Linux** node in the cluster, and any node level targets on each node can be scraped by providing scrape jobs in this configmap. When you use this configmap, you can use `$NODE_IP` variable in your scrape config, which gets substituted by corresponding node's ip address in DaemonSet pod running on each node. This way you get access to scrape anything that runs on that node from the metrics addon DaemonSet. **Please be careful when you use discoveries in scrape config in this node level config map, as every node in the cluster will setup & discover the target(s) and will collect redundant metrics**.
32+
This config map can be used to provide Prometheus scrape config for addon DaemonSet that runs on every **Linux** node in the cluster, and any node level targets on each node can be scraped by providing scrape jobs in this configmap. When you use this configmap, you can use `$NODE_IP` variable in your scrape config, which gets substituted by corresponding node's ip address in DaemonSet pod running on each node. This way you get access to scrape anything that runs on that node from the metrics addon DaemonSet. **Please be careful when you use discoveries in scrape config in this node level config map, as every node in the cluster will setup & discover the target(s) and will collect redundant metrics**.
3333
You can take the sample configmap from the above git hub repo, add scrape jobs that you would need and apply/deploy the config map to `kube-system` namespace for your cluster
3434
4. [`ama-metrics-prometheus-config-node-windows`](https://aka.ms/azureprometheus-addon-ds-configmap-windows) (**Advanced**)
35-
This config map can be used to provide Prometheus scrape config for addon DaemonSet that runs on every **Windows** node in the cluster, and node level targets on each node can be scraped by providing scrape jobs in this configmap. When you use this configmap, you can use `$NODE_IP` variable in your scrape config, which will be substituted by corresponding node's ip address in DaemonSet pod running on each node. This way you get access to scrape anything that runs on that node from the metrics addon DaemonSet. **Please be careful when you use discoveries in scrape config in this node level config map, as every node in the cluster will setup & discover the target(s) and will collect redundant metrics**.
35+
This config map can be used to provide Prometheus scrape config for addon DaemonSet that runs on every **Windows** node in the cluster, and node level targets on each node can be scraped by providing scrape jobs in this configmap. When you use this configmap, you can use `$NODE_IP` variable in your scrape config, which will be substituted by corresponding node's ip address in DaemonSet pod running on each node. This way you get access to scrape anything that runs on that node from the metrics addon DaemonSet. **Please be careful when you use discoveries in scrape config in this node level config map, as every node in the cluster will setup & discover the target(s) and will collect redundant metrics**.
3636
You can take the sample configmap from the above git hub repo, add scrape jobs that you would need and apply/deploy the config map to `kube-system` namespace for your cluster
3737

3838
## Metrics add-on settings configmap
@@ -308,6 +308,54 @@ metric_relabel_configs:
308308
regex: '.+'
309309
```
310310
311+
### TLS based scraping
312+
313+
If you have a Prometheus instance served with TLS and you want to scrape metrics from it, you need to set scheme to `https` and set the TLS settings in your configmap or respective CRD. You can use the `tls_config` configuration property inside a custom scrape job to configure the TLS settings either using a CRD or a configmap. You need to provide a CA certificate to validate API server certificate with. The CA certificate is used to verify the authenticity of the server's certificate when Prometheus connects to the target over TLS. It helps ensure that the server's certificate is signed by a trusted authority.
314+
315+
The secret should be created in kube-system namespace and then the configmap/CRD should be created in kube-system namespace. The order of secret creation matters. When there's no secret but a valid CRD/config map, you will find errors in collector log -> `no file found for cert....`
316+
317+
Below are the details about how to provide the TLS config settings through a configmap or CRD.
318+
319+
- To provide the TLS config setting in a configmap, please create the self-signed certificate and key inside /etc/prometheus/certs directory inside your mtls enabled app.
320+
An example tlsConfig inside the config map should look like this:
321+
322+
```yaml
323+
tls_config:
324+
ca_file: /etc/prometheus/certs/client-cert.pem
325+
cert_file: /etc/prometheus/certs/client-cert.pem
326+
key_file: /etc/prometheus/certs/client-key.pem
327+
insecure_skip_verify: false
328+
```
329+
330+
- To provide the TLS config setting in a CRD, please create the self-signed certificate and key inside /etc/prometheus/certs directory inside your mtls enabled app.
331+
An example tlsConfig inside a Podmonitor should look like this:
332+
333+
```yaml
334+
tlsConfig:
335+
ca:
336+
secret:
337+
key: "client-cert.pem" # since it is self-signed
338+
name: "ama-metrics-mtls-secret"
339+
cert:
340+
secret:
341+
key: "client-cert.pem"
342+
name: "ama-metrics-mtls-secret"
343+
keySecret:
344+
key: "client-key.pem"
345+
name: "ama-metrics-mtls-secret"
346+
insecureSkipVerify: false
347+
```
348+
> [!NOTE]
349+
> Make sure that the certificate file name and key name inside the mtls app is in the following format in case of a CRD based scraping.
350+
For example: secret_kube-system_ama-metrics-mtls-secret_cert-name.pem and secret_kube-system_ama-metrics-mtls-secret_key-name.pem.
351+
> The CRD needs to be created in kube-system namespace.
352+
> The secret name should exactly be ama-metrics-mtls-secret in kube-system namespace. An example command for creating secret: kubectl create secret generic ama-metrics-mtls-secret --from-file=secret_kube-system_ama-metrics-mtls-secret_client-cert.pem=secret_kube-system_ama-metrics-mtls-secret_client-cert.pem --from-file=secret_kube-system_ama-metrics-mtls-secret_client-key.pem=secret_kube-system_ama-metrics-mtls-secret_client-key.pem -n kube-system
353+
354+
To read more on TLS authentication, the following documents might be helpful.
355+
356+
- Generating TLS certificates -> https://o11y.eu/blog/prometheus-server-tls/
357+
- Configurations -> https://prometheus.io/docs/alerting/latest/configuration/#tls_config
358+
311359
## Next steps
312360

313361
[Setup Alerts on Prometheus metrics](./container-insights-metric-alerts.md)<br>

0 commit comments

Comments
 (0)