You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/containers/prometheus-metrics-scrape-configuration.md
+42-6Lines changed: 42 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -505,17 +505,38 @@ Scraping targets using basic auth is currently not supported using pod/service m
505
505
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.
506
506
Please follow the below steps.
507
507
508
-
1. Create a secret object using the TLS certificate in the **kube-system** namespace named **ama-metrics-mtls-secret**.
508
+
1. Create a secret object using the TLS certificate in the **kube-system** namespace named **ama-metrics-mtls-secret**. Inside the secret object , you can specify as many number of secret values under data section and name them how ever you want.
509
+
Each secret name-value pair specified in the data section of the secret object will be mounted as a seperate file in this /etc/prometheus/certs location with filename(s) same as key(s) specified in the data section.
510
+
The secret values should be base64 encoded before putting them under the data section, in case of creating secret with YAML as shown below.
511
+
509
512
Below is an example command for creating a secret using the TLS self-signed certificate, in case of CRD based scraping. Please make sure that the secret object is created using the file naming format exactly as in the example below, in case of a CRD based scraping.
Below is an example of creating secret through YAML, in case of config map based scraping.
517
523
518
-
2. Below are the details about how to provide the TLS config settings through a configmap or CRD.
524
+
```yaml
525
+
apiVersion: v1
526
+
kind: Secret
527
+
metadata:
528
+
name: ama-metrics-mtls-secret
529
+
namespace: kube-system
530
+
type: Opaque
531
+
data:
532
+
<certfile>: base64_cert_content
533
+
<keyfile>: base64_key_content
534
+
```
535
+
The **ama-metrics-mtls-secret** secret is mounted on to the ama-metrics containers at path - **/etc/prometheus/certs/** and is made available to the process that is scraping prometheus metrics. The key( ex - certfile) in the above example will be the file name and the value is base64 decoded and added to the contents of the file within the container and the prometheus scraper uses the contents of this file to get the value that is used as the password used to scrape the endpoint.
536
+
537
+
2. Below are the details about how to provide the TLS config settings through a configmap or CRD.
538
+
539
+
### [Scrape Config using Config File](#tab/ConfigFileScrapeConfigTLSAuth)
519
540
520
541
- To provide the TLS config setting in a configmap, please follow the below example.
521
542
@@ -527,7 +548,10 @@ tls_config:
527
548
insecure_skip_verify: false
528
549
```
529
550
530
-
- To provide the TLS config setting in a configmap, please follow the below example.
551
+
---
552
+
### [Scrape Config using CRD(Pod/Service Monitor)](#tab/CRDScrapeConfigTLSAuth)
553
+
554
+
- To provide the TLS config setting in a CRD(Pod/Service Monitor), please follow the below example.
531
555
532
556
```yaml
533
557
tlsConfig:
@@ -545,15 +569,27 @@ tlsConfig:
545
569
insecureSkipVerify: false
546
570
```
547
571
572
+
---
548
573
> [!NOTE]
549
-
>
550
-
> Pod and Service monitors currently do not support basic authentication. Support for the same is coming up soon.
551
574
>
552
575
> The **/etc/prometheus/certs/** path is mandatory, but *password1* can be any string and needs to match the key for the data in the secret created above. This is because the secret **ama-metrics-mtls-secret** is mounted in the path **/etc/prometheus/certs/** within the container.
553
576
>
554
577
> The base64 encoded value is automatically decoded by the agent pods when the secret is mounted as file.
555
578
>
556
579
> Make sure the secret name is **ama-metrics-mtls-secret** and it is in **kube-system** namespace.
580
+
>
581
+
> If you want to use both basic and Tls authentication settings in your configmap/CRD, just make sure that the secret **ama-metrics-mtls-secret** includes all the files(keys) under the data section with their corresponding base 64 encoded values, as shown below.
582
+
apiVersion: v1
583
+
kind: Secret
584
+
metadata:
585
+
name: ama-metrics-mtls-secret
586
+
namespace: kube-system
587
+
type: Opaque
588
+
data:
589
+
<certfile>: base64_cert_content # used for Tls
590
+
<keyfile>: base64_key_content # used for Tls
591
+
password1: <base64-encoded-string> # used for basic auth
592
+
password2: <base64-encoded-string> # used for basic auth
557
593
>
558
594
> The secret should be created 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....`
0 commit comments