27 Apr 2023 10:42 AM - last edited on 28 Apr 2023 07:21 AM by MaciejNeumann
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:
I've read through your docs a few times and I am not sure how I should tackle this.
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?
Solved! Go to Solution.
12 Jun 2023 11:43 AM
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
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