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
This how-to guide provides steps and utility scripts to [Arc connect](/azure/azure-arc/servers/overview) the Nexus Kubernetes cluster Virtual Machines to Azure and enable monitoring agents for the collection of System logs from these VMs using [Azure Monitoring Agent](/azure/azure-monitor/agents/agents-overview).
45
+
This how-to guide provides steps to enable monitoring agents for the collection of System logs from these VMs using [Azure Monitoring Agent](/azure/azure-monitor/agents/agents-overview).
46
46
The instructions further capture details on how to set up log data collection into a Log Analytics workspace.
47
47
48
-
The following resources provide you with support:
49
-
50
-
-`arc-connect.env`: use this template file to create environment variables needed by included scripts
-`dcr.sh`: use this script to create a Data Collection Rule (DCR) to configure syslog collection
53
-
[!INCLUDE [dcr.sh](./includes/dcr.md)]
54
-
-`assign.sh`: use the script to create a policy to associate the DCR with all Arc-enabled servers in a resource group
55
-
[!INCLUDE [assign.sh](./includes/assign.md)]
56
-
-`install.sh`: Install Azure Monitoring Agent on each VM to collect monitoring data from Azure Virtual Machines.
57
-
[!INCLUDE [install.sh](./includes/install.md)]
58
-
59
-
### Prerequisites-VM
48
+
### Prerequisites
60
49
61
50
- Cluster administrator access to the Nexus Kubernetes cluster.
62
51
@@ -84,127 +73,14 @@ Assign the service principal to the Azure resource group that has the machines t
84
73
|[User Access Administrator](../role-based-access-control/built-in-roles.md#user-access-administrator), and [Resource Policy Contributor](../role-based-access-control/built-in-roles.md#resource-policy-contributor) or [Contributor](../role-based-access-control/built-in-roles.md#contributor)| Needed if you want to use Azure policy assignment(s) to ensure that a DCR is associated with [Arc-enabled machines](https://ms.portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fd5c37ce1-5f52-4523-b949-f19bf945b73a)|
85
74
|[Kubernetes Extension Contributor](../role-based-access-control/built-in-roles.md#kubernetes-extension-contributor)| Needed to deploy the K8s extension for Container Insights |
86
75
87
-
### Environment setup
88
-
89
-
Copy and run the included scripts. You can run them from an
90
-
[Azure Cloud Shell](../cloud-shell/overview.md), in the Azure portal. Or you can run them from a Linux command
91
-
prompt where the Kubernetes command line tool (kubectl) and Azure CLI are installed.
92
-
93
-
Prior to running the included scripts, define the following environment variables:
| SUBSCRIPTION_ID | The ID of the Azure subscription that contains the resource group |
98
-
| RESOURCE_GROUP | The resource group name where Arc-enabled server and associated resources are created |
99
-
| LOCATION | The Azure Region where the Arc-enabled servers and associated resources are created |
100
-
| SERVICE_PRINCIPAL_ID | The appId of the Azure service principal with appropriate role assignment(s) |
101
-
| SERVICE_PRINCIPAL_SECRET | The authentication password for the Azure service principal |
102
-
| TENANT_ID | The ID of the tenant directory where the service principal exists |
103
-
| PROXY_URL | The proxy URL to use for connecting to Azure services |
104
-
| NAMESPACE | The namespace where the Kubernetes artifacts are created |
105
-
106
-
For convenience, you can modify the template file, `arc-connect.env`, to set the environment variable values.
107
-
108
-
```bash
109
-
# Apply the modified values to the environment
110
-
./arc-connect.env
111
-
```
112
-
113
-
### Add a data collection rule (DCR)
114
-
115
-
Associate the Arc-enabled servers with a DCR to enable the collection of log data into a Log Analytics workspace.
116
-
You can create the DCR via the Azure portal or CLI.
117
-
Information on creating a DCR to collect data from the VMs is available [here](/azure/azure-monitor/agents/data-collection-rule-azure-monitor-agent).
118
-
119
-
The included **`dcr.sh`** script creates a DCR, in the specified resource group, that will configure log collection.
120
-
121
-
1. Ensure proper [environment setup](#environment-setup) and role [prerequisites](#prerequisites-vm) for the service principal. The DCR is created in the specified resource group.
122
-
123
-
2. Create or identify a Log Analytics workspace for log data ingestion as per the DCR. Set an environment variable, LAW_RESOURCE_ID to its resource ID. Retrieve the resource ID for a known Log Analytics workspace name:
124
-
125
-
```bash
126
-
export LAW_RESOURCE_ID=$(az monitor log-analytics workspace show -g "${RESOURCE_GROUP}" -n <law name> --query id -o tsv)
127
-
```
128
-
129
-
3. Run the dcr.sh script. It creates a DCR in the specified resource group with name ${RESOURCE_GROUP}-syslog-dcr
130
-
131
-
```bash
132
-
./dcr.sh
133
-
```
134
-
135
-
View/manage the DCR from the Azure portal or [CLI](/cli/azure/monitor/data-collection/rule).
136
-
By default, the Linux Syslog log level is set to "INFO". You can change the log level as needed.
137
-
138
-
> [!NOTE]
139
-
> Manually, or via a policy, associate servers created prior to the DCR's creation.
140
-
See [remediation task](../governance/policy/how-to/remediate-resources.md#create-a-remediation-task).
141
-
142
-
### Associate Arc-enabled server resources to DCR
143
-
144
-
Associate the Arc-enabled server resources to the created DCR for logs to flow to the Log Analytics workspace.
145
-
There are options for associating servers with DCRs.
146
-
147
-
#### Use Azure portal or CLI to associate selected Arc-enabled servers to DCR
148
-
149
-
In Azure portal, add Arc-enabled server resource to the DCR using its Resources section.
76
+
### Monitor Nexus Kubernetes cluster
150
77
151
-
Use this [link](/cli/azure/monitor/data-collection/rule/association#az-monitor-data-collection-rule-association-create)
152
-
for information about associating the resources via the Azure CLI.
153
-
154
-
### Use Azure policy to manage DCR associations
155
-
156
-
Assign a policy to the resource group to enforce the association.
157
-
There's a built-in policy definition, to associate [Linux Arc Machines with a DCR](https://ms.portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fd5c37ce1-5f52-4523-b949-f19bf945b73a). Assign the policy to the resource group with DCR as a parameter.
158
-
It ensures association of all Arc-enabled servers, within the resource group, with the same DCR.
159
-
160
-
In the Azure portal, select the `Assign` button from the [policy definition](https://ms.portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fd5c37ce1-5f52-4523-b949-f19bf945b73a) page.
161
-
162
-
For convenience, the provided **`assign.sh`** script assigns the built-in policy to the specified resource group and DCR created with the **`dcr.sh`** script.
163
-
164
-
1. Ensure proper [environment setup](#environment-setup) and role [prerequisites](#prerequisites-vm) for the service principal to do policy and role assignments.
165
-
2. Create the DCR, in the resource group, using **`dcr.sh`** script as described in [Adding a Data Collection Rule](/azure/azure-monitor/essentials/data-collection-endpoint-overview?tabs=portal#create-a-data-collection-endpoint) section.
166
-
3. Run the **`assign.sh`** script. It creates the policy assignment and necessary role assignments.
167
-
168
-
```bash
169
-
./assign.sh
170
-
```
171
-
172
-
#### Install Azure monitoring agent
173
-
174
-
Use the included **`install.sh`** which creates a Kubernetes daemonSet on the Nexus Kubernetes cluster.
175
-
It deploys a pod to each cluster node and installs the Azure Monitoring Agent (AMA).
176
-
The `daemonSet` also includes a liveness probe that monitors the server connection and AMA processes.
177
-
> [!NOTE]
178
-
> To install Azure Monitoring Agent, you must first Arc connect the Nexus Kubernetes cluster VMs. This process is automated if you are using the latest version bundle. However, if the version bundle you use does not support cluster VM Arc enrollment by default, you will need to upgrade your cluster to the latest version bundle. For more information about the version bundle, please refer [Nexus Kubernetes cluster supported versions](reference-nexus-kubernetes-cluster-supported-versions.md)
179
-
180
-
1. Set the environment as specified in [Environment Setup](#environment-setup). Set the current `kubeconfig` context for the Nexus Kubernetes cluster VMs.
181
-
2. Permit `Kubectl` access to the Nexus Kubernetes cluster.
3. Run the **`install.sh`** script from the command prompt with kubectl access to the Nexus Kubernetes cluster.
184
-
185
-
The script deploys the `daemonSet` to the cluster. Monitor the progress as follows:
186
-
187
-
```bash
188
-
# Run the install script and observe results
189
-
./install.sh
190
-
kubectl get pod --selector='name=naks-vm-telemetry'
191
-
kubectl logs <podname>
192
-
```
193
-
194
-
On completion, the system logs the message "Server monitoring configured successfully".
195
-
196
-
> [!NOTE]
197
-
> Associate these connected servers to the [DCR](#associate-arc-enabled-server-resources-to-dcr).
198
-
After you configure a policy, there may be some delay to observe the logs in Azure Log Analytics Workspace
199
-
200
-
### Monitor Nexus Kubernetes cluster – K8s layer
201
-
202
-
#### Prerequisites-Kubernetes
78
+
#### Prerequisites
203
79
204
80
There are certain prerequisites the operator should ensure to configure the monitoring tools on Nexus Kubernetes Clusters.
205
81
206
82
Container Insights stores its data in a [Log Analytics workspace](/azure/azure-monitor/logs/log-analytics-workspace-overview).
207
-
Log data flows into the workspace whose Resource ID you provided during the initial scripts covered in the ["Add a data collection rule (DCR)"](#add-a-data-collection-rule-dcr) section.
83
+
Log data flows into the workspace whose Resource ID you provided during the installation of the Container Insights extension.
208
84
Else, data funnels into a default workspace in the Resource group associated with your subscription (based on Azure location).
209
85
210
86
An example for East US may look like follows:
@@ -284,7 +160,39 @@ Look for a Provisioning State of "Succeeded" for the extension. The "k8s-extensi
284
160
285
161
#### Customize logs & metrics collection
286
162
287
-
Container Insights provides end-users functionality to fine-tune the collection of logs and metrics from Nexus Kubernetes Clusters--[Configure Container insights agent data collection](/azure/azure-monitor/containers/container-insights-data-collection-configmap).
163
+
Container Insights provides end-users functionality to fine-tune the collection of logs and metrics from Nexus Kubernetes Clusters. See the instructions for [Configure Container insights agent data collection](/azure/azure-monitor/containers/container-insights-data-collection-configure) for more information.
164
+
165
+
166
+
> [!NOTE]
167
+
> Container Insights does not collect logs from the `kube-system` namespace by default. To collect logs from the `kube-system` namespace, you must configure the agent to collect logs from the `kube-system` namespace.
168
+
> This can be done by removing the `kube-system` namespace from the `excludedNamespaces` field in the ConfigMap following the [`configMap` configuraiton](/azure/azure-monitor/containers/container-insights-data-collection-configure?tabs=portal#configure-data-collection-using-configmap) approach.
169
+
> ```
170
+
> [log_collection_settings]
171
+
> [log_collection_settings.stdout]
172
+
> # In the absense of this configmap, default value for enabled is true
173
+
> enabled = true
174
+
> # exclude_namespaces setting holds good only if enabled is set to true
175
+
> # kube-system,gatekeeper-system log collection are disabled by default in the absence of 'log_collection_settings.stdout' setting. If you want to enable kube-system,gatekeeper-system, remove them from the following setting.
176
+
> # If you want to continue to disable kube-system,gatekeeper-system log collection keep the namespaces in the following setting and add any other namespace you want to disable log collection to the array.
177
+
> # In the absense of this configmap, default value for exclude_namespaces = ["kube-system","gatekeeper-system"]
178
+
> exclude_namespaces = ["gatekeeper-system"]
179
+
> # If you want to collect logs from only selective pods inside system namespaces add them to the following setting. Provide namepace:controllerName of the system pod. NOTE: this setting is only for pods in system namespaces
180
+
> # Valid values for system namespaces are: kube-system, azure-arc, gatekeeper-system, kube-public, kube-node-lease, calico-system. The system namespace used should not be present in exclude_namespaces
> # exclude_namespaces setting holds good only if enabled is set to true
187
+
> # kube-system,gatekeeper-system log collection are disabled by default in the absence of 'log_collection_settings.stderr' setting. If you want to enable kube-system,gatekeeper-system, remove them from the following setting.
188
+
> # If you want to continue to disable kube-system,gatekeeper-system log collection keep the namespaces in the following setting and add any other namespace you want to disable log collection to the array.
189
+
> # In the absense of this configmap, default value for exclude_namespaces = ["kube-system","gatekeeper-system"]
190
+
> exclude_namespaces = ["gatekeeper-system"]
191
+
> # If you want to collect logs from only selective pods inside system namespaces add them to the following setting. Provide namepace:controllerName of the system pod. NOTE: this setting is only for pods in system namespaces
192
+
> # Valid values for system namespaces are: kube-system, azure-arc, gatekeeper-system, kube-public, kube-node-lease, calico-system. The system namespace used should not be present in exclude_namespaces
0 commit comments