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
+45-51Lines changed: 45 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -466,12 +466,9 @@ metric_relabel_configs:
466
466
467
467
If you are using `basic_auth` setting in your prometheus configuration, please follow the steps -
468
468
469
-
Below is an example of creating a secret.
470
-
471
-
1. Create a secret object 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.
472
-
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.
473
-
The secret values should be base64 encoded before putting them under the data section.
469
+
1. Create a secret in the **kube-system** namespace named **ama-metrics-mtls-secret**
474
470
471
+
The value for password1 is **base64encoded**
475
472
The key *password1* can be anything, but just needs to match your scrapeconfig *password_file* filepath.
476
473
477
474
```yaml
@@ -500,26 +497,17 @@ Scraping targets using basic auth is currently not supported using pod/service m
500
497
501
498
---
502
499
500
+
If you are using both basic auth and tls auth, please refer to the [section](#create-secret-using-yaml-for-both-basic-and-tls-auth) below.
501
+
For more details, refer to the [note section](#note-section).
502
+
503
+
503
504
### TLS based scraping
504
505
505
506
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
507
Please follow the below steps.
507
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
-
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
-
512
-
### [Create secret with command for CRD based scraping](#tab/CommandSecretCRD)
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.
1. Create a secret in the kube-system namespace named ama-metrics-mtls-secret. Each key-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. The secret values should be base64 encoded before putting them under the data section, like below.
510
+
523
511
Below is an example of creating secret through YAML.
524
512
525
513
```yaml
@@ -534,24 +522,6 @@ Please follow the below steps.
534
522
<keyfile>: base64_key_content
535
523
```
536
524
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
525
---
556
526
557
527
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.
@@ -570,27 +540,51 @@ Please follow the below steps.
570
540
key_file: /etc/prometheus/certs/<keyfile>
571
541
insecure_skip_verify: false
572
542
```
543
+
573
544
### [Scrape Config using CRD(Pod/Service Monitor)](#tab/CRDScrapeConfigTLSAuth)
574
545
575
546
- To provide the TLS config setting in a CRD(Pod/Service Monitor), please follow the below example.
576
547
577
548
```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
549
+
tlsConfig:
550
+
ca:
551
+
secret:
552
+
key: "<certfile>" # since it is self-signed
553
+
name: "ama-metrics-mtls-secret"
554
+
cert:
555
+
secret:
556
+
key: "<certfile>"
557
+
name: "ama-metrics-mtls-secret"
558
+
keySecret:
559
+
key: "<keyfile>"
560
+
name: "ama-metrics-mtls-secret"
561
+
insecureSkipVerify: false
591
562
```
592
563
593
564
---
565
+
566
+
567
+
### Create secret using YAML for both basic and Tls auth
568
+
569
+
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.
570
+
571
+
```yaml
572
+
573
+
apiVersion: v1
574
+
kind: Secret
575
+
metadata:
576
+
name: ama-metrics-mtls-secret
577
+
namespace: kube-system
578
+
type: Opaque
579
+
data:
580
+
certfile: base64_cert_content # used for Tls
581
+
keyfile: base64_key_content # used for Tls
582
+
password1: base64-encoded-string # used for basic auth
583
+
password2: base64-encoded-string # used for basic auth
584
+
585
+
```yaml
586
+
587
+
<a name="note-section"></a>
594
588
> [!NOTE]
595
589
>
596
590
> 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.
0 commit comments