Configure Azure Log Analytics as a health source
In Harness, a health source is a mapping of a Harness service to a service running in a deployment environment that is being monitored by an Application Performance Monitoring (APM) or logging tool. This mapping allows Harness to collect metrics and data from the APM or logging tool and use it to determine the health and status of the service in Harness.
This topic describes how to set up Azure Log Analytics as a health source in a monitored service.
Prerequisites
- An Azure Log Analytics connector has been added to the Harness platform.
- A monitored service has already been created in the Harness SRM.
Add Azure Log Analytics health source
To add Azure Log Analytics as a health source:
- In the Health Sources section, select Add. The Add New Health Source dialog appears.
- On the Define Health Source tab, do the following:
- In the Define Health Source section, select Azure Log Analytics as health source type.
- In the Health Source Name field, enter a name for the health source.
- In the Connect Health Source section, select the Select Connector.
The Create or Select an Existing Connector dialog appears. - Select a connector for the Azure Logs health source and then select Apply Selected.
The selected connector appears in the Select Connector dropdown field. - In the Select Feature, you can either select Azure Log Analytics*.
- Select Next.
The Configuration tab appears.
Define metric and log configuration settings
Perform the following steps based on the feature you have selected in the Select Feature field.
Steps to configure Azure Cloud Metrics in Azure Log Analytics
- On the Configuration tab, select Add Metric.
The Add Metric dialog appears. - Enter the following information and then select Submit:
- Metric name: Enter a name for the metric. For example, Memory Metric.
- Group name: If the group where you want to add the metric already exists, select it.
If you want to create a new group, select Add New. In the Add Group Name settings, enter a group name, and then select Submit.
- In the Add Metric dialog, select Submit.
The new group and metric are created. The query specifications and mapping settings are displayed. These settings help you get the desired metric data from the Azure Log Analytics platform and map it to a Harness service. To learn about Azure Log Analytics and queries, go to Azure Monitor Logs.
Define a query
- Resource ID - the Azure resource Id you wish to target for the query,
- Metric namespace - the Azure metric namespace you want to target for the query.
- Metric name - The name of the metric you wish to query on.
- Aggregation - Aggregations allow you to summarize raw log data to create more compact, meaningful, and actionable information. You can perform calculations such as counting, summing, averaging, minimum, and maximum on numeric data, and you can also perform operations like counting unique values or grouping data by specific attributes.
- Average
- Maximum
- Minimum
- Total
- Count
You can find the values necessary for each query using the Azure UI. Generally you need to follow these steps:
- Select the Azure Metric you want to analyze.
- Click on the
Share
option in the dashboard and selectCopy Link
. - Input your URL into a URL decoder. This should result in you seeing a JSON payload.
- In the JSON payload you decoded, you should be able to find the resource ID, metric namespace, and metric name.
Assign services
In the Assign section, select the services where you want to apply the Azure Logs metric. Following options are available:
- Continuous Verification (applied to pipelines in Continuous Deployment): Select this option to use the metric data in the Continuous Deployment pipeline to ensure that the deployed service is running safely and to perform automatic rollbacks. In addition, the metric will be used to apply machine learning in detecting and highlighting future deployment issues.
- Service Health: Select this option to use the metric data to track the changes in the health trend of your monitored service.
- Service Level Indicator (SLI): Select this option to use the metric data to measure the SLI and obtain the performance of the service.
Configure risk profile
If you select Continuous Verification (applied to pipelines in Continuous Deployment) or Service Health, expand the section below and follow the instructions for configuring the risk profile.
Risk Profile
The Risk Profile section is only visible if you have selected Continuous Verification (applied to pipelines in Continuous Deployment) or Service Health in the Assign section.
- Under Risk Category, select one of the following options:
- Errors
- Infrastructure
- Performance/Throughput
- Performance/Other
- Performance/Response Time
- Under Deviation Compared To Baseline, select the following settings to measure your service's behavior and calculate deviations from the health source:
- Higher counts = higher risk
- Lower counts = higher risk
You can select multiple options.
Map service instance identifier
The Map service instance identifier section is only visible if you have selected Continuous Verification (applied to pipelines in Continuous Deployment) in the Assign section.
In Service Instance Identifier (only needed for CV), specify the service instance identifier, which represents a dynamically created service that you deploy using Harness. The default value is _sourceHost
.
Advanced (Optional)
The Advanced (Optional) section is only visible if you have selected Continuous Verification (applied to pipelines in Continuous Deployment) in the Assign section.
Ignore Thresholds
You can select the types of events that you want to set thresholds for in CV. Metrics that match the selected rules will not be flagged as anomalous, regardless of the analysis.
To set the Ignore Thresholds for CV:
- Go to the Ignore Thresholds tab and select the Add Threshold button.
- From the Metric dropdown, select the desired metric for which you want to set the rule.
- In Criteria, choose the type of criteria you want to apply for the threshold:
- Absolute Value: Select this option and enter the Greater than and Lesser than values.
- Percentage Deviation: Select this option and enter the Lesser than value.
Fail-Fast Thresholds
You can select the type of events for which you want to set thresholds in CV. Any metric that matches the selected rules will be marked as anomalous and cause the Workflow state to fail.
To set fail-fast thresholds for CV, follow these steps:
- Go to the Fail-Fast Thresholds tab and select the + Add Threshold button.
- From the Metric dropdown, select the desired metric for which you want to set the rule.
- In the Action field, select what the CV should do when applying the rule:
- Fail Immediately
- Fail after multiple occurrences
- Fail after consecutive occurrences
-
In the Count field, set the number of occurrences. This setting is only visible if you have selected Fail after multiple occurrences or Fail after consecutive occurrences in the Action field. The minimum value must be two.
-
In the Criteria field, choose the type of criteria you want to apply for the threshold:
- Absolute Value: Select this option and enter the Greater than and Lesser than values.
- Percentage Deviation: Select this option and enter the Lesser than value.
Steps to configure Azure Analytics Cloud Logs in Azure Log Analytics
- On the Configuration tab, select + Add Query.
The Add Query dialog appears. - Enter a name for the query and then select Submit.
The Custom Queries settings are displayed. These settings assist in retrieving the desired logs from the Azure Logs platform and mapping them to the Harness service. To learn about Azure Logs logs, go to Azure Monitor Logs.
Define a query
- In Resource Id / Workspace Id, enter the Azure Resource Id or Workspace Id you want to target.
- In the Query field, enter the log query and select Run Query to execute it. This displays a sample record in the Records field, allowing you to confirm the accuracy of the query you've constructed.
- In the Field Mapping section, select the Service Instance Identifier to display the logs, and then select Get sample log messages. Sample logs are displayed that help you verify if the query you built is correct.
Save the health source settings
- After configuring all the settings, select Submit. The Azure Logs health source gets added to the monitored service.