Skip to content

Commit 2b8093c

Browse files
authored
Merge pull request #84900 from MGoedtel/1582121
Container Insights - Updated info on Prometheus support
2 parents 55fe756 + 8daae72 commit 2b8093c

File tree

3 files changed

+72
-14
lines changed

3 files changed

+72
-14
lines changed

articles/azure-monitor/insights/container-insights-agent-config.md

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ ms.service: azure-monitor
1111
ms.topic: article
1212
ms.tgt_pltfrm: na
1313
ms.workload: infrastructure-services
14-
ms.date: 07/12/2019
14+
ms.date: 08/14/2019
1515
ms.author: magoedte
1616
---
1717

1818
# Configure agent data collection for Azure Monitor for containers
1919

20-
Azure Monitor for containers collects stdout, stderr, and environmental variables from container workloads deployed to managed Kubernetes clusters hosted on Azure Kubernetes Service (AKS) from the containerized agent. This agent can also collect time series data (also referred to as metrics) from Prometheus using the containerized agent without having to setup and manage a Prometheus server and database. You can configure agent data collection settings by creating a custom Kubernetes ConfigMaps to control this experience.
20+
Azure Monitor for containers collects stdout, stderr, and environmental variables from container workloads deployed to managed Kubernetes clusters hosted on Azure Kubernetes Service (AKS) from the containerized agent. This agent can also collect time series data (also referred to as metrics) from Prometheus using the containerized agent without having to set up and manage a Prometheus server and database. You can configure agent data collection settings by creating a custom Kubernetes ConfigMaps to control this experience.
2121

2222
This article demonstrates how to create ConfigMap and configure data collection based on your requirements.
2323

2424
>[!NOTE]
2525
>Support for Prometheus is a feature in public preview at this time.
2626
>
2727
28-
## Configure your cluster with custom data collection settings
28+
## ConfigMap file settings overview
2929

3030
A template ConfigMap file is provided that allows you to easily edit it with your customizations without having to create it from scratch. Before starting, you should review the Kubernetes documentation about [ConfigMaps](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/) and familiarize yourself with how to create, configure, and deploy ConfigMaps. This will allow you to filter stderr and stdout per namespace or across the entire cluster, and environment variables for any container running across all pods/nodes in the cluster.
3131

3232
>[!IMPORTANT]
3333
>The minimum agent version supported to collect stdout, stderr, and environmental variables from container workloads is ciprod06142019 or later. The minimum agent version supported for scraping Prometheus metrics is ciprod07092019 or later. To verify your agent version, from the **Node** tab select a node, and in the properties pane note value of the **Agent Image Tag** property.
3434
35-
### Overview of configurable data collection settings
35+
### Data collection settings
3636

3737
The following are the settings that can be configured to control data collection.
3838

@@ -46,21 +46,33 @@ The following are the settings that can be configured to control data collection
4646
|`[log_collection_settings.stderr] exclude_namespaces =` |String |Comma-separated array |Array of Kubernetes namespaces for which stderr logs will not be collected. This setting is effective only if `log_collection_settings.stdout.enabled` is set to `true`. If not specified in ConfigMap, the default value is `exclude_namespaces = ["kube-system"]`. |
4747
| `[log_collection_settings.env_var] enabled =` |Boolean | true or false | This controls if environment variable collection is enabled. When set to `false`, no environment variables are collected for any container running across all pods/nodes in the cluster. If not specified in ConfigMap, the default value is `enabled = true`. |
4848

49-
## Overview of configurable Prometheus scraping settings
49+
### Prometheus scraping settings
5050

51-
Active scraping of metrics from Prometheus are performed from one of two perspectives:
51+
![Container monitoring architecture for Prometheus](./media/container-insights-agent-config/monitoring-kubernetes-architecture.png)
52+
53+
Azure Monitor for containers provides a seamless experience to enable collection of Prometheus metrics by multiple scraping through the following mechanisms as shown in the following table. The metrics are collected through a set of settings specified in a single ConfigMap file, which is the same file used to configure collection of stdout, stderr, and environmental variables from container workloads.
54+
55+
Active scraping of metrics from Prometheus is performed from one of two perspectives:
5256

5357
* Cluster-wide - HTTP URL and discover targets from listed endpoints of a service, k8s services such as kube-dns and kube-state-metrics, and pod annotations specific to an application. Metrics collected in this context will be defined in the ConfigMap section *[Prometheus data_collection_settings.cluster]*.
5458
* Node-wide - HTTP URL and discover targets from listed endpoints of a service. Metrics collected in this context will be defined in the ConfigMap section *[Prometheus_data_collection_settings.node]*.
5559

60+
| Endpoint | Scope | Example |
61+
|----------|-------|---------|
62+
| Pod annotation | Cluster-wide | annotations: <br>`prometheus.io/scrape: "true"` <br>`prometheus.io/path: "/mymetrics"` <br>`prometheus.io/port: "8000" <br>prometheus.io/scheme: "http"` |
63+
| Kubernetes service | Cluster-wide | `http://my-service-dns.my-namespace:9100/metrics` <br>`https://metrics-server.kube-system.svc.cluster.local/metrics`|
64+
| url/endpoint | Per-node and/or cluster-wide | `http://myurl:9101/metrics` |
65+
66+
When a URL is specified, Azure Monitor for containers only scrapes the endpoint. When Kubernetes service is specified, the service name is resolved with the cluster DNS server to get the IP address and then the resolved service is scraped.
67+
5668
|Scope | Key | Data type | Value | Description |
5769
|------|-----|-----------|-------|-------------|
5870
| Cluster-wide | | | | Specify any one of the following three methods to scrape endpoints for metrics. |
5971
| | `urls` | String | Comma-separated array | HTTP endpoint (Either IP address or valid URL path specified). For example: `urls=[$NODE_IP/metrics]`. ($NODE_IP is a specific Azure Monitor for containers parameter and can be used instead of node IP address. Must be all uppercase.) |
6072
| | `kubernetes_services` | String | Comma-separated array | An array of Kubernetes services to scrape metrics from kube-state-metrics. For example,`kubernetes_services = ["https://metrics-server.kube-system.svc.cluster.local/metrics",http://my-service-dns.my-namespace:9100/metrics]`.|
6173
| | `monitor_kubernetes_pods` | Boolean | true or false | When set to `true` in the cluster-wide settings, Azure Monitor for containers agent will scrape Kubernetes pods across the entire cluster for the following Prometheus annotations:<br> `prometheus.io/scrape:`<br> `prometheus.io/scheme:`<br> `prometheus.io/path:`<br> `prometheus.io/port:` |
62-
| | `prometheus.io/scrape` | Boolean | true or false | Enables scraping of the pod. |
63-
| | `prometheus.io/scheme` | String | http or https | Defaults to scrapping over HTTP. If required, set to `https`. |
74+
| | `prometheus.io/scrape` | Boolean | true or false | Enables scraping of the pod. `monitor_kubernetes_pods` must be set to `true`. |
75+
| | `prometheus.io/scheme` | String | http or https | Defaults to scrapping over HTTP. If necessary, set to `https`. |
6476
| | `prometheus.io/path` | String | Comma-separated array | The HTTP resource path on which to fetch metrics from. If the metrics path is not `/metrics`, define it with this annotation. |
6577
| | `prometheus.io/port` | String | 9102 | Specify a port to listen on. If port is not set, it will default to 9102. |
6678
| Node-wide | `urls` | String | Comma-separated array | HTTP endpoint (Either IP address or valid URL path specified). For example: `urls=[$NODE_IP/metrics]`. ($NODE_IP is a specific Azure Monitor for containers parameter and can be used instead of node IP address. Must be all uppercase.) |
@@ -69,16 +81,59 @@ Active scraping of metrics from Prometheus are performed from one of two perspec
6981

7082
ConfigMap is a global list and there can be only one ConfigMap applied to the agent. You cannot have another ConfigMap overruling the collections.
7183

72-
### Configure and deploy ConfigMaps
84+
## Configure and deploy ConfigMaps
7385

7486
Perform the following steps to configure and deploy your ConfigMap configuration file to your cluster.
7587

7688
1. [Download](https://github.com/microsoft/OMS-docker/blob/ci_feature_prod/Kubernetes/container-azm-ms-agentconfig.yaml) the template ConfigMap yaml file and save it as container-azm-ms-agentconfig.yaml.
7789
1. Edit the ConfigMap yaml file with your customizations.
7890

7991
- To exclude specific namespaces for stdout log collection, you configure the key/value using the following example: `[log_collection_settings.stdout] enabled = true exclude_namespaces = ["my-namespace-1", "my-namespace-2"]`.
92+
8093
- To disable environment variable collection for a specific container, set the key/value `[log_collection_settings.env_var] enabled = true` to enable variable collection globally, and then follow the steps [here](container-insights-manage-agent.md#how-to-disable-environment-variable-collection-on-a-container) to complete configuration for the specific container.
94+
8195
- To disable stderr log collection cluster-wide, you configure the key/value using the following example: `[log_collection_settings.stderr] enabled = false`.
96+
97+
- The following examples demonstrates how to configure the ConfigMap file metrics from a URL cluster-wide, from an agent's DameonSet node-wide, and by specifying a pod annotation
98+
99+
- Scrape Prometheus metrics from a specific URL across the cluster.
100+
101+
```
102+
prometheus-data-collection-settings: |- ​
103+
# Custom Prometheus metrics data collection settings
104+
[prometheus_data_collection_settings.cluster] ​
105+
interval = "1m" ## Valid time units are ns, us (or µs), ms, s, m, h.
106+
fieldpass = ["metric_to_pass1", "metric_to_pass12"] ## specify metrics to pass through ​
107+
fielddrop = ["metric_to_drop"] ## specify metrics to drop from collecting
108+
urls = ["http://myurl:9101/metrics"] ## An array of urls to scrape metrics from
109+
```
110+
111+
- Scrape Prometheus metrics from an agent's DaemonSet running in every node in the cluster.
112+
113+
```
114+
prometheus-data-collection-settings: |- ​
115+
# Custom Prometheus metrics data collection settings ​
116+
[prometheus_data_collection_settings.node] ​
117+
interval = "1m" ## Valid time units are ns, us (or µs), ms, s, m, h. ​
118+
# Node level scrape endpoint(s). These metrics will be scraped from agent's DaemonSet running in every node in the cluster ​
119+
urls = ["http://$NODE_IP:9103/metrics"] ​
120+
fieldpass = ["metric_to_pass1", "metric_to_pass2"] ​
121+
fielddrop = ["metric_to_drop"] ​
122+
```
123+
124+
- Scrape Prometheus metrics by specifying a pod annotation.
125+
126+
```
127+
prometheus-data-collection-settings: |- ​
128+
# Custom Prometheus metrics data collection settings
129+
[prometheus_data_collection_settings.cluster] ​
130+
interval = "1m" ## Valid time units are ns, us (or µs), ms, s, m, h
131+
monitor_kubernetes_pods = true #replicaset will scrape Kubernetes pods for the following prometheus annotations: ​
132+
- prometheus.io/scrape:"true" #Enable scraping for this pod ​
133+
- prometheus.io/scheme:"http:" #If the metrics endpoint is secured then you will need to set this to `https`, if not default ‘http’​
134+
- prometheus.io/path:"/mymetrics" #If the metrics path is not /metrics, define it with this annotation. ​
135+
- prometheus.io/port:"8000" #If port is not 9102 use this annotation​
136+
```
82137
83138
1. Create ConfigMap by running the following kubectl command: `kubectl apply -f <configmap_yaml_file.yaml>`.
84139
@@ -93,7 +148,7 @@ To verify the configuration was successfully applied, use the following command
93148
config::unsupported/missing config schema version - 'v21' , using defaults
94149
```
95150
96-
Errors related to applying configuration changes for Prometheus are also available for review. Either from the logs from an agent pod using the same `kubectl logs` command or from live logs. Live logs shows errors similar to the following:
151+
Errors related to applying configuration changes for Prometheus are also available for review. Either from the logs from an agent pod using the same `kubectl logs` command or from live logs. Live logs show errors similar to the following:
97152
98153
```
99154
2019-07-08T18:55:00Z E! [inputs.prometheus]: Error in plugin: error making HTTP request to http://invalidurl:1010/metrics: Get http://invalidurl:1010/metrics: dial tcp: lookup invalidurl on 10.0.0.10:53: no such host
@@ -103,7 +158,7 @@ Errors prevent omsagent from parsing the file, causing it to restart and use the
103158
104159
## Applying updated ConfigMap
105160
106-
If you have already deployed a ConfigMap to your cluster and you want to update it with a newer configuration, you can simply edit the ConfigMap file you've previously used and then apply using the same command as before, `kubectl apply -f <configmap_yaml_file.yaml`.
161+
If you have already deployed a ConfigMap to your cluster and you want to update it with a newer configuration, you can edit the ConfigMap file you've previously used and then apply using the same command as before, `kubectl apply -f <configmap_yaml_file.yaml`.
107162
108163
The configuration change can take a few minutes to finish before taking effect, and all omsagent pods in the cluster will restart. The restart is a rolling restart for all omsagent pods, not all restart at the same time. When the restarts are finished, a message is displayed that's similar to the following and includes the result: `configmap "container-azm-ms-agentconfig" updated`.
109164

articles/azure-monitor/insights/container-insights-faq.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ editor: tysonn
88
ms.service: azure-monitor
99
ms.topic: article
1010
ms.workload: infrastructure-services
11-
ms.date: 08/02/2019
11+
ms.date: 08/14/2019
1212
ms.author: magoedte
1313

1414
---
@@ -29,7 +29,7 @@ If you are unable to see any data in the Log Analytics workspace at a certain ti
2929

3030
The ContainerInventory table contains information about both stopped and running containers. The table is populated by a workflow inside the agent that queries the docker for all the containers (running and stopped), and forwards that data the Log Analytics workspace.
3131

32-
## How do I resolve **Missing Subscription registration** error?
32+
## How do I resolve *Missing Subscription registration* error?
3333

3434
If you receive the error **Missing Subscription registration for Microsoft.OperationsManagement**, you can resolve it by registering the resource provider **Microsoft.OperationsManagement** in the subscription where the workspace is defined. The documentation for how to do this can be found [here](../../azure-resource-manager/resource-manager-register-provider-errors.md).
3535

@@ -67,7 +67,7 @@ LogEntry : ({“Hello": "This example has multiple lines:","Docker/Moby": "will
6767
6868
```
6969

70-
For a detailed look at the issue, review the following [github link](https://github.com/moby/moby/issues/22920).
70+
For a detailed look at the issue, review the following [GitHub link](https://github.com/moby/moby/issues/22920).
7171

7272
## How do I resolve Azure AD errors when I enable live logs?
7373

@@ -82,6 +82,9 @@ If after you enable Azure Monitor for containers for an AKS cluster, you delete
8282
- *.oms.opinsights.azure.com 443
8383
- *.blob.core.windows.net 443
8484
- dc.services.visualstudio.com 443
85+
- *.microsoftonline.com 443
86+
- *.monitoring.azure.com 443
87+
- login.microsoftonline.com 443
8588

8689
## Next steps
8790

0 commit comments

Comments
 (0)