Skip to content

Commit 8d5adfb

Browse files
Update the TLS section of the doc
1 parent 36956ad commit 8d5adfb

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

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

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,10 @@ If you are using `basic_auth` setting in your prometheus configuration, please f
467467

468468
Below is an example of creating a secret.
469469

470-
1. Create a secret object in the **kube-system** namespace named **ama-metrics-mtls-secret**.
470+
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.
471+
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.
472+
The secret values should be base64 encoded before putting them under the data section.
471473

472-
473-
The value for password1 is **base64encoded**
474474
The key *password1* can be anything, but just needs to match your scrapeconfig *password_file* filepath.
475475

476476
```yaml
@@ -497,53 +497,42 @@ basic_auth:
497497
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.
498498
Please follow the below steps.
499499

500-
1. Create a secret object in the **kube-system** namespace named **ama-metrics-mtls-secret**. Example command for creating secret below:
501-
```console
502-
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
500+
1. Create a secret object using the TLS certificate in the **kube-system** namespace named **ama-metrics-mtls-secret**.
501+
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.
502+
```console
503+
kubectl create secret generic ama-metrics-mtls-secret --from-file=secret_kube-system_ama-metrics-mtls-secret_<certfile>=secret_kube-system_ama-metrics-mtls-secret_<certfile> --from-file=secret_kube-system_ama-metrics-mtls-secret_<keyfile>=secret_kube-system_ama-metrics-mtls-secret_<keyfile> -n kube-system
503504
```
505+
Below is an example command for creating a secret using the TLS self-signed certificate, in case of config map based scraping.
506+
```console
507+
kubectl create secret generic ama-metrics-mtls-secret --from-file=<certfile>=<certfile> --from-file=<keyfile>=<keyfile> -n kube-system
508+
```
504509

505-
The value for password1 is **base64encoded**
506-
The key *password1* can be anything, but just needs to match with the keys/filenames mentioned in your CRD/Configmap.
507-
508-
```yaml
509-
apiVersion: v1
510-
kind: Secret
511-
metadata:
512-
name: ama-metrics-mtls-secret
513-
namespace: kube-system
514-
type: Opaque
515-
data:
516-
password1: <base64-encoded-string>
517-
```
518-
519-
2. Below are the details about how to provide the TLS config settings through a configmap or CRD.
510+
2. Below are the details about how to provide the TLS config settings through a configmap or CRD.
520511

521-
- To provide the TLS config setting in a configmap, please create the self-signed certificate and key inside your mtls enabled app.
522-
An example tlsConfig inside the config map should look like this:
512+
- To provide the TLS config setting in a configmap, please follow the below example.
523513

524514
```yaml
525515
tls_config:
526-
ca_file: /etc/prometheus/certs/client-cert.pem
527-
cert_file: /etc/prometheus/certs/client-cert.pem
528-
key_file: /etc/prometheus/certs/client-key.pem
516+
ca_file: /etc/prometheus/certs/<certfile> # since it is self-signed
517+
cert_file: /etc/prometheus/certs/<certfile>
518+
key_file: /etc/prometheus/certs/<keyfile>
529519
insecure_skip_verify: false
530520
```
531521

532-
- To provide the TLS config setting in a CRD, please create the self-signed certificate and key inside your mtls enabled app.
533-
An example tlsConfig inside a Podmonitor should look like this:
522+
- To provide the TLS config setting in a configmap, please follow the below example.
534523

535524
```yaml
536525
tlsConfig:
537526
ca:
538527
secret:
539-
key: "client-cert.pem" # since it is self-signed
528+
key: "<certfile>" # since it is self-signed
540529
name: "ama-metrics-mtls-secret"
541530
cert:
542531
secret:
543-
key: "client-cert.pem"
532+
key: "<certfile>"
544533
name: "ama-metrics-mtls-secret"
545534
keySecret:
546-
key: "client-key.pem"
535+
key: "<keyfile>"
547536
name: "ama-metrics-mtls-secret"
548537
insecureSkipVerify: false
549538
```
@@ -556,15 +545,9 @@ tlsConfig:
556545
>
557546
> The base64 encoded value is automatically decoded by the agent pods when the secret is mounted as file.
558547
>
559-
> Any other configuration setting for authorization that is considered as a secret in the [prometheus configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) needs to use the file setting alternative instead as described above.
560-
>
561-
> Make sure the name is **ama-metrics-mtls-secret** and it is in **kube-system** namespace.
562-
>
563-
> Inside the secret object , you can specify as many number of secret values under data section and name them how ever you want. 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. The secret values should be base64 encoded before putting them under the data section.
564-
>
565-
> Please make sure that the mounted secret object is created using the command above and the file naming is followed as-is, in case of a CRD based scraping.
548+
> Make sure the secret name is **ama-metrics-mtls-secret** and it is in **kube-system** namespace.
566549
>
567-
> 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....`
550+
> 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....`
568551
>
569552
> To read more on TLS configuration settings, please follow this [Configurations](https://aka.ms/tlsconfigsetting).
570553

0 commit comments

Comments
 (0)