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
+65-59Lines changed: 65 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -508,64 +508,87 @@ Please follow the below steps.
508
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
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
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
-
511
+
512
+
### [Create secret with command for CRD based scraping](#tab/CommandSecretCRD)
512
513
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.
522
+
### [Create secret using YAML](#tab/YAMLSecret)
523
+
Below is an example of creating secret through YAML.
524
+
525
+
```yaml
526
+
apiVersion: v1
527
+
kind: Secret
528
+
metadata:
529
+
name: ama-metrics-mtls-secret
530
+
namespace: kube-system
531
+
type: Opaque
532
+
data:
533
+
<certfile>: base64_cert_content
534
+
<keyfile>: base64_key_content
535
+
```
536
+
537
+
### [Create secret using YAML for both basic and Tls auth](#tab/YAMLSecretBasicTls)
538
+
539
+
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.
540
+
541
+
```yaml
542
+
apiVersion: v1
543
+
kind: Secret
544
+
metadata:
545
+
name: ama-metrics-mtls-secret
546
+
namespace: kube-system
547
+
type: Opaque
548
+
data:
549
+
certfile: base64_cert_content # used for Tls
550
+
keyfile: base64_key_content # used for Tls
551
+
password1: base64-encoded-string # used for basic auth
552
+
password2: base64-encoded-string # used for basic auth
553
+
```yaml
554
+
555
+
---
556
+
557
+
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.
523
558
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
559
537
560
2. Below are the details about how to provide the TLS config settings through a configmap or CRD.
538
561
539
562
### [Scrape Config using Config File](#tab/ConfigFileScrapeConfigTLSAuth)
540
563
541
-
- To provide the TLS config setting in a configmap, please follow the below example.
542
-
543
-
```yaml
544
-
tls_config:
545
-
ca_file: /etc/prometheus/certs/<certfile> # since it is self-signed
546
-
cert_file: /etc/prometheus/certs/<certfile>
547
-
key_file: /etc/prometheus/certs/<keyfile>
548
-
insecure_skip_verify: false
549
-
```
564
+
- To provide the TLS config setting in a configmap, please follow the below example.
565
+
566
+
```yaml
567
+
tls_config:
568
+
ca_file: /etc/prometheus/certs/<certfile> # since it is self-signed
569
+
cert_file: /etc/prometheus/certs/<certfile>
570
+
key_file: /etc/prometheus/certs/<keyfile>
571
+
insecure_skip_verify: false
572
+
```
550
573
### [Scrape Config using CRD(Pod/Service Monitor)](#tab/CRDScrapeConfigTLSAuth)
551
574
552
-
- To provide the TLS config setting in a CRD(Pod/Service Monitor), please follow the below example.
553
-
554
-
```yaml
555
-
tlsConfig:
556
-
ca:
557
-
secret:
558
-
key: "<certfile>" # since it is self-signed
559
-
name: "ama-metrics-mtls-secret"
560
-
cert:
561
-
secret:
562
-
key: "<certfile>"
563
-
name: "ama-metrics-mtls-secret"
564
-
keySecret:
565
-
key: "<keyfile>"
566
-
name: "ama-metrics-mtls-secret"
567
-
insecureSkipVerify: false
568
-
```
575
+
- To provide the TLS config setting in a CRD(Pod/Service Monitor), please follow the below example.
576
+
577
+
```yaml
578
+
tlsConfig:
579
+
ca:
580
+
secret:
581
+
key: "<certfile>" # since it is self-signed
582
+
name: "ama-metrics-mtls-secret"
583
+
cert:
584
+
secret:
585
+
key: "<certfile>"
586
+
name: "ama-metrics-mtls-secret"
587
+
keySecret:
588
+
key: "<keyfile>"
589
+
name: "ama-metrics-mtls-secret"
590
+
insecureSkipVerify: false
591
+
```
569
592
570
593
---
571
594
> [!NOTE]
@@ -575,23 +598,6 @@ tlsConfig:
575
598
> The base64 encoded value is automatically decoded by the agent pods when the secret is mounted as file.
576
599
>
577
600
> Make sure the secret name is **ama-metrics-mtls-secret** and it is in **kube-system** namespace.
578
-
>
579
-
> 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.
580
-
581
-
```yaml
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
593
-
```yaml
594
-
595
601
>
596
602
> 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