Datadog and metrics issues list

I am using Datadog. I have some questions.
I am sending only 2 requests in default function: create and read. Both requests are contained in a separate group so I can segregate measurements over groups.

Here is the list of custom metrics I am using in the script:

let createFailRate = new Rate(‘Create failed requests’);
let readFailRate = new Rate(‘Read failed requests’);
let createDurationTrend = new Trend(‘Create requests duration’);
let readDurationTrend = new Trend(‘Read requests duration’);
let createWaitingTrend = new Trend(‘Create requests waiting’);
let readWaitingTrend = new Trend(‘Read requests waiting’);
let createBlockedTrend = new Trend(‘Create requests blocked’);
let readBlockedTrend = new Trend(‘Read requests blocked’);
let allErrors = new Counter(‘error_counter’);

Here is how I am using allErrors and other metrics:

createResult = http.post(‘URL’, requestBody, headers);
check(createResult, {
‘Create Asset Instance: is status 201’: (r) => r.status == 202,
});

if (createResult.status != 202) {
  console.log(`create asset instance status: ${res.status}`);
  if (createResult.status == 404) {
    console.log(`status 404`);
    allErrors.add(1, { errorType: '404 Error  : Entry Not Found' });
  }
  else if (createResult.status == 500) {
    console.log(`status 500`);
    allErrors.add(1, { errorType: '500 Error  : Internal server error' });
  }
  else if (createResult.status == 502) {
    console.log(`status 502`);
    allErrors.add(1, { errorType: '502 Error  : Bad Gateway Error' });
  }
  else if (createResult.status == 503) {
    console.log(`status 503`);
    allErrors.add(1, { errorType: '503 Error  : Service Unavailable Error' });
  }
}
createFailRate.add(createResult.status != 202);
createDurationTrend.add(createResult.timings.duration);
createWaitingTrend.add(createResult.timings.waiting);
createBlockedTrend.add(createResult.timings.blocked);

I have some questions on how or maybe what metrics are sent, How to get what I want.
Q1: In Datadog I see k6. Read_requests_duration.95percentile metric and similar other 95 percentile metrics when I am configuring timeseries graph. How to get 75p, 90p, 99p for the trend metrics?
Q2: How do I get information regarding error occurred during script execution. I already have failed request trends for both requests types. I can’t get to see the error types in Datadog. I am not sure if this is a DD graph configuration issue or something I can do in the script or simple K6 is not sending the measurement. My objective is to get/see error count for each request type and error type. I am using heatmap to achieve this but I am only getting the count.

Hi there,

  1. You can configure the percentiles to calculate in the Datadog Agent.
    If you’re using the Docker image, you can pass it the DD_HISTOGRAM_PERCENTILES environment variable. So the full command would be:

    DOCKER_CONTENT_TRUST=1 \
    docker run -d \
        --name datadog \
        -v /var/run/docker.sock:/var/run/docker.sock:ro \
        -v /proc/:/host/proc/:ro \
        -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
        -e DD_SITE="datadoghq.com" \
        -e DD_API_KEY=<YOUR_DATADOG_API_KEY> \
        -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=1 \
        -e DD_HISTOGRAM_PERCENTILES='0.75 0.90 0.95 0.99' \
        -p 8125:8125/udp \
        datadog/agent:latest
    

    See additional documentation here: Docker Agent for Docker, containerd, and Podman

  2. I think that your current approach with the error_counter metric is fine for this purpose. I’m not very familiar with Datadog’s graphs, but are you sure that heatmap is the right graph for this counter metric?
    To me it makes sense as a timeseries graph, but make sure to select “avg by: errortype”, otherwise it won’t display it by tag.
    See how it looks for me: