cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get time-series data that includes string values into Dynatrace?

msavy
Frequent Guest

Hi Everyone,

I maintain an open-source API Management project; we have a rich time-series data stream that we output that is very useful for analytics (typically into Elasticsearch or InfluxDB etc). We call it metrics, but it doesn't really map perfectly onto Dynatrace's definition of metrics — I would write a plugin for the platform to allow it to push that data directly to Dynatrace (e.g. via OneAgent or to the cloud).

My first instinct was to use the Dynatrace Metrics v2 API, but I'm not sure whether I'm trying to bash a square peg into a round hole. It really only seems to want the values to be numbers (literal number, gauge, or counter), and not strings. For example, a classic value would be the endpoint that was accessed.

Here is what a single metric record looks like from the API Management solution (pseudo-code to demonstrate the data, ignore the specific format). Each request-response through the gateway would produce its own record, which we aggregate, transform into platform-specific formats, and then push into the corresponding platform.

apiId="foo" // identifier
apiOrgId="test" // identifier
apiVersion="1.0" // identifier
requestStart="1682448091736" // timestamp for when request started
requestEnd="1682448092015" // timestamp for when request ended
apiStart="1682448091739" // timestamp (similar to above, but backend only)
apiEnd="1682448092013" // timestamp (similar to above, but backend only)
url="https://localhost:8443/apiman-gateway/test/foo/1.0"
method="GET" // HTTP Method that was proxied
responseCode="200" // HTTP response code
responseMessage="OK" // HTTP response message
failureCode="0" // If an error occurred its code would be shown here
error="false"
custom.request.header.X-Correlation-Id="1234-4949-4693" // Some custom header captured by the user's config

From reading the Dynatrace documentation and using your definitions, depending how you squint at this, a dataset like this could be:

  •  An event (represents a single request-response action);
  • A log (records what happened in detail, and can be used for audit);
  • A metric (some of this information could be transformed into counters, gauges, and values)

 

I've read through your docs a few times and I am not sure how I should tackle this.

 

  •  Do I need to emit multiple Dynatrace metrics for each example metric as shown above? For example, you _could_ put the endpoint as an additional dimension, but this seems likely to cause an explosion in dimensions.

 

  • Some of the metric values are essentially enums/text and not numeric — I am not sure how these would map across to a gauge or counter. For example, HTTP method, response messages, or custom captured header key-values.

 

  •  Is there a different API I should be looking at instead? I can see some examples of existing platforms that seem to be able to get the full raw per-request data in, not just counters/gauges. So I suppose there must be a way to do it.

 

  • For example, people want specific response codes for each request, and using metrics it seems you'd realistically need to batch into 4xx, 5xx, etc. This means you'd be losing some of the fidelity of the data. Or again, you'd need a cross-product of a huge range of dimensions (and/or keys), which would get out of control fairly quickly I suspect?

 

All guidance is much appreciated.

 

TL;DR: I'd like a way to get the sample data into Dynatrace, and ideally also provide some metadata/schema (etc), to allow Dynatrace to understand the meaning of the data. Is this possible via APIs?

1 REPLY 1

mark_bley
Dynatrace Pro
Dynatrace Pro

Hi @msavy ,

you could indeed use metrics to ingest the data you are referring to like follows

failureCode,piid="foo",apiorgid="test",apiversion="1.0",requeststart="1682448091736",requestend="1682448092015",apistart="1682448091739",apiend="1682448092013",url="https://localhost:8443/apiman-gateway/test/foo/1.0",method="get",responsecode="200",responsemessage="ok",error="false",custom.request.header.x-correlation-id="1234-4949-4693" 0

I took the value from failureCode since it seems to make the most sense to have it as as a metric data point.

Using a data explorer you could plot the metric data in a graph and filter/split by any of the dimensions passed through

mark_bley_0-1686566156332.png

From this you can use metric events to generate problems as needed, display the data on dashboards etc.

You could as well ingest data as logs and extract metrics from the logs or directly throw events from depending on content in the log line. 

However from the data you sent it seems you are trying to figure out the state of a specific application depending on the response, we usually do this with synthetic tests. You can define specifically how and when a test fails, you can also define postprocessing scripts to further analyze the payload received from the endpoint you are checking.

Sending this data as events would e.g. make the querying of data a bit more challenging if you want to view the state of your application in a specific timeframe, sending events requires as well some kind of entity in Dynatrace to send the events to.

Hope this helps.

Best,

Mark

Featured Posts