Integration of Datadog Custom metrics in JavaScript k6 project

Hello,
I have a project in k6 where I execute some scenarios, send the metrics and tags to Datadog and look at them through a dashboard.

The problem is that the metrics I want doesn’t exist, we got individual metrics of every check, but no global metrics that could englobe them all to show them easily in the dashboard. The possible solution would be to do dashboard with all the metrics of the checks, but that mean adding them by hand, have to maintain them by hand and we have a lot of checks through the scenario.

The way to fix all this with Datadog is to use a custom metrics with the DogStatsD client ( DogStatsD ). I did my configuration of the client like that :

use_dogstatsd: true
dogstatsd_port: 8125

dogstatsd_mapper_profiles:
- name: my_custom_metric_test
prefix: custom_metric.
mappings:
- match: ‘k6.check.*’
match_type: wildcard
name: custom_metric.check

And then, I should initialize the client in the k6 project, but I dont really know where I should do so, and how, because the Datadog’s page talk about ways to do it in Python, Ruby, Go, Java, PHP, NET but not in Javascript.

So if anyone already have this type of configuration and manage to make his custom metric appear on Datadog, I would appreciate any tips !

Thanks in advance,
Arthis

I am not very familiar with DataDog, but from glancing at the link you provided, DogStatsD seems like a part of the DataDog agent, which you are usually supposed to run on the same machine you run k6 on. That is, this isn’t something you configure from k6, it is a separate process/container. It seems like, by default, it listens on port 8125 on localhost, which is where the statsd k6 output will send metrics to. We also have some DataDog specific instructions here: Datadog

1 Like

Hello,
Thanks for your answer, but i think you misunderstand which part of the implementation I was talking about.
For the configuration of the process, I think I got it, but as it’s explain on the datadog page :


I need to initialise this client inside my k6 projects, but I don’t know how to ( as my project is in JavaScript and not Java or Go) and where to (I tried in my entry file but didnt succeed in doing it)