API & HTTP Headers: How to Use Request Headers in API Checks

In previous posts we covered why it’s important to monitor APIs and how to monitor and validate data from APIs. In this post we’ll focus on a simple but key feature that helps Splunk Synthetic Monitoring users create robust checks for availability, response time, and multi-step processes: Request Headers

What are API & HTTP Request Header?

When we talk about Request Headers, we’re referring to fields passed along in the header sections of HTTP requests. Request Headers can include rules and settings to define how an HTTP transaction should operate. Headers are found in the message body and include metadata about:

  1. The request and response body
  2. Authorization for the request
  3. Caching of the response
  4. Response cookies

Headers typically come just after the request or response line in a key-value pair separate by a colon, as follows:

{
 "key1": "value1",
 "key2": " value2",
 "key3": " value3",
}

There is a standard set of supported Request Header types that have specific names and purposes. Some common examples of Request Headers would be:

Some developers may also implement Custom Request Headers with custom names. It’s common to see Custom Request Headers with a pre-fix of “X,” for example: X-Http-Method-Override could override the request method from something like POST to another method like PUT or DELETE.

Depending on how a site or application works, Request Headers may be a critical part of requirements for an active monitoring test’s configuration to effectively simulate a transaction. For example, if we need to actively test the way that a checkout process works when a visitor is cookied, then we’ll need some way to set that cookie with a Request Header when we build an active test on that transaction.

How can we use Request Headers in API Checks?

Splunk Synthetic Monitoring’s API Check helps us monitor the availability, response time and data quality for transactions with APIs. With an API Check, we can set request headers with each Request as part of a transaction.

Consider a scenario where we need to POST username and password credentials to access some information. Then once we’re logged in at that endpoint we need to store and set a session ID in order to pre-populate other components specific to our session.

When building the steps for an API Check, we can click + Add a Request Header to supply one or more headers at each request step.

In the example above, we’re using Splunk Synthetic Monitoring’s API Check to:

We could continue to add more functional steps to this transaction or add an Assert step to confirm that the session ID is set as expected.

Why is this valuable?

Request Headers for API Checks seem like a no-brainer today, but our attention to this feature didn’t originate in conversations about requirements for our new API Check; user requests for Request Headers helped us discover that the API Check feature might be worth developing.

Splunk Synthetic Monitoring users let us know that they needed the ability to add Request Headers to each step in their existing Uptime checks. As we continued to have conversations with people about how they expected Request Headers to work within their Uptime check settings, we learned that many teams needed this functionality so that they could monitor robust functionality of APIs. This sparked more conversations that helped us scope out the requirements for a brand new type of Splunk Synthetic Monitoring check specifically designed with API monitoring in mind.

We’re happy to support the ability to set multiple Request Headers for individual steps in transactions as part of our new API Check feature. We know these super basic components open up endless possibilities for simulating and monitoring API transactions.

Video: Learn more about API & HTTP Headers: How to Use Request Headers in API Checks

Related Articles

What Is Syslog?
Learn
6 Minute Read

What Is Syslog?

Learn what Syslog is and how it can help you identify and troubleshoot problems as an IT professional.
What is a DBMS (Database Management System)?
Learn
6 Minute Read

What is a DBMS (Database Management System)?

Getting started with databases? From relational, to object-orientated, here's our beginner's guide to Database Management Systems!
Data Governance vs. Data Management: Differences Explained
Learn
6 Minute Read

Data Governance vs. Data Management: Differences Explained

Understanding the difference between data governance and data management is paramount in any setting where you’re managing (and monetizing) data.