I want to push with statsd (prometheus) an array of objects containing user_id and other properties specific to said user. The goal is to be able to display on a graph a number of user depending on chosen property. As an example, this is the value I want to push:
[
{
"user_id": "b3726d1d-e947-4035-bd98-87bddbca1c2b",
"premium": false,
"basic": false
},
{
"user_id": "a2b9e909-0e35-48b2-a7d6-0a554f802159",
"premium": false,
"basic": true
},
{
"user_id": "1e91df33-122b-4199-adff-a001e7864221",
"premium": true,
"basic": false
}
]
And I want to be able to choose premium property in Grafana and get a number of premium users on the graph counted. How can I make it worked? This is how I tried to do it...
In the script that pushes the data, it looks like this:
const userStatistics = await UserRepository.getUserStatistics();
statsD.default.gauge("user_statistics", userStatistics);
where userStatistics is the value mentioned before. Do I have to also push a number of total users to Grafana, or is this not needed? And if so, do I just push it as a seperate value? As in
statsD.default.gauge("totalCountOfUsers", totalCountOfUsers);
The idea for it is to be a scalable solution, as I think new properties are also gonna be added in the future, that's why I'm thinking of doing this that way... Anyone could help out with this?
When I tried the solution above, the metrics didn't show up at all.