OBLYTECH Logo
OBLYTECH Logo

Create Azure policies for metric collection

To create Azure policies for metric collection, build an Agent Client Collector policy for the required Azure CIs, attach the Azure Metrics Collector check, configure its proxy and credentials, and supply the metric and resource configuration. Use this approach when a resource needs collection coverage beyond the policies included with the base system.

Decide whether a custom Azure policy is needed

Start with the resource you need to monitor and the metrics that would answer an operational question about it. A custom policy fills a resource coverage gap. Azure Metrics Batch API calls are how metric values reach the agent, and the Azure Metrics Collector check is the component that makes those calls. The policy connects that check to the CIs, credentials, proxy agent, and configuration needed for collection.

Review the included Azure policies before building another one. If an existing policy covers the resource, activation may be the appropriate task. Activating an included policy involves assigning credentials, editing it in the Agent Client Collector Monitoring scope, selecting its proxy agent, saving, and using Republish. Creating a custom policy follows the separate construction steps below.

The base system already includes preconfigured policies for Azure Load Balancer, Azure Gateway, Azure Redis Cache, Azure Storage Account, and Azure Virtual Machine (VM) metrics. Each one collects metrics for its resource type and lists the metrics it supports, so check that list against your resource before you decide to build from scratch.

Pick the collection source before configuring the policy: Agent Client Collector for this policy, or a metric pull connector configured from the Integrations Launchpad. Keep that collection choice clear before configuring the policy. For the broader context, see the plain-language guide to Operational Metrics. A clear source decision helps prevent a team from investigating the wrong collection path when data is missing.

Prepare the CIs and policy editing context

The role required to create this custom policy is agent_client_collector_admin. The CIs you intend to monitor must already be in the CMDB; Discovery typically supplies them. Inspect a representative CI before writing the filter so that its type, Object ID, and State can be matched deliberately.

Discovery is the usual route for getting CIs into the CMDB. It scans the infrastructure and records what it finds there.

Open All > System Properties > All Properties and set sn_agent.multi_ci_dev_mode to true. Check these settings and labels on your instance and release before making changes. For the surrounding Azure collection setup, prepare an active MID Server and metric base, install Agent Client Collector Framework and Agent Client Collector Monitoring, and run Discovery on the Azure cloud account.

Write down the CI type, resource name, namespace, metric list, proxy agent and configuration filename before you open the policy form. A reviewer can then check each value against one list instead of hunting through several forms.

Agree who will maintain the credential and proxy configuration alongside the policy. The Operational Metrics security and access design page can support that discussion. Avoid putting actual credential values in the working record.

Create the policy and confirm its CI selection

  1. Open All > Agent Client Collector > Policies and select New.
  2. Check that the scope picker reads Agent Client Collector Monitoring, then type the policy name into the Name field.
  3. Open Monitored CIs and select Monitored CI type by filter.
  4. Choose the Monitored CI type that matches the resource represented in the JSON configuration.
  5. Configure Object ID to equal the resource name used in that configuration, and set State to Available.
  6. Use Preview to get a count of matching CIs, then click that count to list the records.

Do more than check whether Preview returns a number. Compare the returned records with the intended resource set. An unexpected match deserves investigation before the check is attached. If the count is zero, review the CI type and both filter conditions against the CMDB record rather than broadening the filter immediately.

Setting State to Available limits the match to CIs in an available state. Other CIs stay out of the policy, so they cannot distort the collected data. Preserve that condition while investigating a missing match. A filter that includes unrelated CIs makes later diagnosis harder because a collection problem and a targeting problem can look similar from the resulting data.

Attach the collector, proxy, and credential parameters

On Checks, find Azure Metrics Collector in Available and move it to Selected with the right arrow. On Proxy Settings, select Single proxy agent, then choose the execution agent in Proxy agent. On Credentials, set Credential name to azure_metrics_collector and select Save.

A proxy agent monitors the CIs on behalf of agents that run in the cloud, and the credential is what gives the agent access to Azure.

Next, open the Azure Metrics Collector check instance in the policy’s Check Instances section. On Check Secure Parameters, select New to add the following entries. Preserve the parameter spelling and order values:

  • cred_tenant_id with Order value 1.
  • cred_client_id with Order value 2.
  • cred_secret_key with Order value 3.

Select Active for each secure parameter, then select Update. Review these entries together: a credential selected on the policy and secure parameters on its check instance are separate pieces of the configuration. Record their presence and order in the review notes without recording secret values.

For an included Azure policy’s activation workflow, credential selection uses Credentials and Credential alias; the available credentials can be viewed at All > Discovery > Credentials with Type=Azure credentials. The activation workflow selects credentials through Credentials and Credential alias, which is a different path from this policy’s Credential name field.

Connect the metric file and generated resource configuration

Open the check instance and its Check Parameters subtab, then select New. Enter a descriptive Name for the configuration file reference. Set Value to the JSON filename and Flag to -c. Select Active, Mandatory, and Value required, then select Submit.

The Value must match the filename uploaded under Agent Client Collector > Configuration Files. For example, acc_azure_vm_metrics_config.json is a filename reference, not a substitute for uploading the file. The configuration contains a namespace and the list of metrics to retrieve. Create the metric configuration for the resource and add that JSON file to Configuration Files.

A custom policy needs two JSON files: one that lists the resources to be monitored and one that lists the metrics to retrieve from those resources. Generate both, upload the metric file under Configuration Files, and keep the resource values aligned with the CI selection you reviewed earlier.

Then configure the resource information. On Proxy Settings, select Multi-CI Mode. Take the script from Config file creation script in an included Azure cloud policy and place it in the same field on the custom policy. At the end of the script, configure resource_id, region, and sys_id using the values for the CI to be monitored.

Review these as two related concerns: the metric configuration identifies the namespace and measurements, while the resource configuration identifies the target resource. A matching filename does not prove that the resource values are correct. Compare both with the CI selection you reviewed earlier.

For help planning this work, see ServiceNow implementation.

Before saving, ask a second reviewer to trace one intended CI through the filter, resource script, and metric file reference. This small review can expose a copied resource identifier or a filename left over from the starting policy. Keep the original resource selection visible during the review so that the check remains tied to the requirement that prompted the custom policy.

Publish with a traceable acceptance check

Select Save and then Publish on the policy. Once published, a working policy pulls the Azure CI’s resources and their metric values and forwards them to the agent. That outcome is what the acceptance check should test. Treat publication as the transition to checking that result, with an agreed resource and metric list available for comparison.

A focused acceptance record should capture the selected CIs, the proxy agent, the uploaded filename, the secure parameter names and order, and the resource_id, region, and sys_id mapping. Compare the received metrics with the intended namespace and list. Distinguish evidence of a saved policy from evidence that the required measurements arrived.

Use the Operational Metrics testing and acceptance checklist to organize wider acceptance work. If data is absent, investigate in dependency order: CI matching, check selection, proxy selection, credential configuration, filename agreement, and resource values. Change one suspected cause at a time and retain the comparison result.

For issues that extend beyond this policy, use the Operational Metrics troubleshooting guide to structure the investigation.