3 - Verify Deployments with Splunk

Updated 1 week ago by Michael Cretzman

The following procedure describes how to add Splunk as a verification step in a Harness workflow. For more information about workflows, see Add a Workflow.

Once you run a deployment and Splunk preforms verification, Harness' machine-learning verification analysis will assess the risk level of the deployment.

In order to obtain the names of the host(s), pod(s), or container(s) where your service is deployed, the verification provider should be added to your workflow after you have run at least one successful deployment.

Deployment Verification Setup

To verify your deployment with Splunk, do the following:

  1. Ensure that you have added Splunk as a verification provider, as described above.
  2. In your workflow, under Verify Service, click Add Verification, and then click Splunkv2. The Splunk V2 dialog appears.

The Splunk dialog has the following fields.

Field

Description

Splunk Server

Select the Harness Verification Provider you configured using your Splunk account.

Search Keywords

Enter a search term or query. To search for all exceptions, use asterisks (*) around exception, for example, *exception*. For more information, see Retrieve events from the index from Splunk.

When you enter a search such as *exception*, at runtime Harness will generate a query containing your search and information Harness needs to perform verification, such as the information following *exception* below:

search *exception* host = ip-172-31-81-88 | bin _time span=1m | 
cluster t=0.9999 showcount=t labelonly=t|
table _time, _raw,cluster_label, host |
stats latest(_raw) as _raw count as cluster_count by _time,cluster_label,host

If you want more flexibility in your search, or to repurpose Splunk searches you already have, you can click Advanced Query and enter whatever you like in Search Keywords. For example, you could replace *exception* with an existing Splunk search like search index=*prod *exception*.

Note that you will specify host field name and host/pod/container name in other settings so you do not need to include them in the search query.

Field name for Host/Container

Typically, you will enter host. You can enter host into the Splunk Search field to see the host for your Harness deployment:

Expression for Host/Container name

See Guide From Example.

Analysis Time duration

Set the duration for the verification step. If a verification step exceeds the value, the workflow Failure Strategy is triggered. For example, if the Failure Strategy is Ignore, then the verification state is marked Failed but the workflow execution continues.

See CV Strategies, Tuning, and Best Practices.

Baseline for Risk Analysis

Canary Analysis - Harness will compare the metrics received for the nodes deployed in each phase with metrics received for the rest of the nodes in the application. For example, if this phase deploys to 25% of your nodes, the metrics received from Splunk during this deployment for these nodes will be compared with metrics received for the other 75% during the defined period of time.

Previous Analysis - Harness will compare the metrics received for the nodes deployed in each phase with metrics received for all the nodes during the previous deployment. For example, if this phase deploys V1.2 to node A, the metrics received from Splunk during this deployment will be compared to the metrics for nodes A, B, and C during the previous deployment (V1.1).

See CV Strategies, Tuning, and Best Practices.

Execute with previous steps

Check this checkbox to run this verification step in parallel with the previous steps in Verify Service.

Guide From Example

This section uses a host field for the Expression for Host/Container name field. For Kubernetes, see Kubernetes and Splunk.

In the Splunk verification step dialog, you can see the Guide From Example option next to the Expression for Host/Container name field. This option lets you select the host(s), pod(s), or container(s) for Harness to use when performing verification.

You select the host, pod, or container in Guide From Example, and an expression is added to the Expression for Host/Container name field. The default expression is ${host.hostName}. Typically, you can simply use ${host.hostName}.

In order to obtain the names of the host(s) pod(s), or container(s) where your service is deployed, the verification provider should be added to your workflow after you have run at least one successful deployment. Then the Guide From Example feature can display the host or container name(s) for you to select.

To ensure that you pick the right name when using Guide From Example, you can use a host name in Splunk as a guide.

To use Guide From Example for a host or container name expression, do the following:

  1. In Splunk, click App: Search & Reporting, and then click Search & Reporting.
  2. In Search, enter host to see a list of the available hosts being tracked.
  3. Click the name of your host to add it to the search, select a date range, and click the search icon. The event log entries for the host appear.
    The name of the host can be seen in the event message, next to host =. The expression that you provide in the Expression for Host/Container Name field in the Harness Splunk dialog should evaluate to the name here.
You might have a different label than host, such as pod_name. You simply use the label that identifies the host or container.
  1. In your Harness workflow Splunk dialog, click Guide From Example. The Expression for Host Name popover appears.
    The dialog shows the service, environment, and service infrastructure used for this workflow.
  2. In Host, click the name of the host to use when testing verification. Match the hostname from the Splunk Search to the hostname in the Expression for Host Name popover:
  3. Click SUBMIT. The YAML for the host appears. Look for the host section.
    You want to use a hostName label in the host section. Do not use a hostName label outside of that section.
  4. Click the hostName label. The variable name is added to the Expression for Host/Container name field.
  5. At the bottom of the Splunk dialog, click TEST. A new Expression for Host Name popover appears.
  6. In Host, select the same host you selected last time, and then click RUN. Verification information for the host is found. In there is no verification data for the selected node, the test will display connection information only.
  7. Click back in the Splunk dialog and click SUBMIT. The Splunk verification step is added to your workflow.

Kubernetes and Splunk

In the Guide From Example section above we used a host example for the Expression for Host/Container name field, but if the Workflow is deploying Kubernetes, you will likely use pod or pod_name or a custom label.

For Kubernetes deployments, your Splunk account must perform Kubernetes log collection. This is typically done using Splunk Connect for Kubernetes. For information on using Splunk Connect, see Deploy Splunk Enterprise on Kubernetes on the Splunk Blog.

In addition, the Splunk fields.conf file should contain the following fields in order to search Kubernetes logs in Splunk:

 [namespace]
INDEXED = true

[pod]
INDEXED = true

[container_name]
INDEXED = true

[container_id]
INDEXED = true

[cluster_name]
INDEXED = true

You can edit fields.conf in $SPLUNK_HOME/etc/system/local/fields.conf or in a custom app directory $SPLUNK_HOME/etc/apps/myapp/local/fields.conf.

Ensure that your Kubernetes deployment is set up to log what you need. See Logging Architecture from Kubernetes.

Verification Results

Once you have deployed your workflow (or pipeline) using the Splunk verification step, you can automatically verify app performance across your deployment. For more information, see Add a Workflow and Add a Pipeline.

Workflow Verification

After you add the Splunk verification step to your workflow, the next time you deploy the workflow you will see the Splunk verification step running:

To see the results of Harness machine-learning evaluation of your Splunk verification, in your workflow or pipeline deployment you can expand the Verify Service step and then click the Splunk step.

Continuous Verification

You can also see the evaluation in the Continuous Verification dashboard. The workflow verification view is for the DevOps user who developed the workflow. The Continuous Verification dashboard is where all future deployments are displayed for developers and others interested in deployment analysis.

To learn about the verification analysis features, see the following sections.

Deployments

Deployment infoSee the verification analysis for each deployment, with information on its service, environment, pipeline, and workflows.

Verification phases and providersSee the vertfication phases for each vertfication provider. Click each provider for logs and analysis.

Verification timelineSee when each deployment and verification was performed.

Transaction Analysis

Execution detailsSee the details of verification execution. Total is the total time the verification step took, and Analysis duration is how long the analysis took.

Risk level analysisGet an overall risk level and view the cluster chart to see events.

Transaction-level summarySee a summary of each transaction with the query string, error values comparison, and a risk analysis summary.

Execution Analysis

Event typeFilter cluster chart events by Unknown Event, Unexpected Frequency, Anticipated Event, Baseline Event, and Ignore Event.

Cluster chartView the chart to see how the selected event contrast. Click each event to see its log details.

Event Management

Event-level analysisSee the threat level for each event captured.

Tune event captureRemove events from analysis at the service, workflow, execution, or overall level.

Event distributionClick the chart icon to see an event distribution including the measured data, baseline data, and event frequency.

Next Steps


How did we do?