API Request for IN/Out msg/s by Node


(Gianluca Valentini) #1

Hi,
I have a Graylog in claster. One master and one slave.
I’d like to know the API to have the in/out throughput to show on another view.

image

Using GET /system/metrics/{metricName} or [GET] /cluster/{nodeId}/metrics/namespace/{namespace} with
org.graylog2.throughput.input.1-sec-rate and org.graylog2.throughput.output.1-sec-rate I always have the 0 result

Where am I doing wrong?

Is there the possibility to have a specific output throughput metric?
I need to know how many messages are going to Kafka. Adding the Kafka Output, How can I understand how many events are actually sent to?

Thanks
Gianluca


(Philipp Ruland) #2

Are you sure that you do not have a typo somewhere? Using copy/paste into postman with your URLs (and replacing the {nodeId} and {metricName} respectively, I get correct results:
Using /cluster/{nodeId}/...


Using /system/metrics/

Another option would be this:

curl "https://graylog.example.local/api/cluster/metrics/multiple" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic <REDACTED>" \
  --data "{""metrics"":[""org.graylog2.throughput.input.1-sec-rate"",""org.graylog2.throughput.output.1-sec-rate""]}"

This returns the requested metrics for each system in your cluster, removing the need to adapt your code if you ever expand your cluster. Example response:

Sadly, I think not (yet)! Every input Graylog has is providing metrics (idk about plugin inputs, but my guess would be, that Graylog applies at least a basic metric set on these), since you can see detailed stats on the System -> Inputs page. The System -> Outputs page is a lot more sparse, which already hints that there are no metrics for outputs.

Have a look at https://graylog.example.local/system/metrics/node/{nodeId} (or click the metrics button of a node in the System -> Nodes page) and filter for .input. or .output., you’ll quickly see which metrics are available or not.

My best guess to get metrics from an output would be to create a feature request in the Graylog Github Issues.

Greetings,
Philipp


(Gianluca Valentini) #3

Hi @DerPhlipsi
thank you so much for the detailed answer.
My concern was caused by the fact that I always value 0 as an answer.
I execute the test on the Grayog swagger view. Now everything is more clear!

Thanks
Gianluca


(Gianluca Valentini) #4

Do you think that is possbile to have output metrics if I implement a custom one?

Would it be visible using metric ReST calls?


(Philipp Ruland) #5

You could do two things: You could either implement your own plugin that adds a output that is reporting metrics via the dropwizard metics library that Graylog is using. These metrics are automatically made available through the Graylog API if you use the metric registry Graylog provides.

The other option would be to fork the Graylog server project, implement a basic set of metrics on the general output classes (similar to the generic input classes, basically a clever copy/paste job) and submit a Pull request. Disclaimer: I did not look further into the source code since I do not have time for that atm, so any statement about “being easy” is to be seen as limited warranty :smiley:

I had a quick look at the Graylog Source Code and it seems that this is a good starting point to start working yourself into how metrics are working: https://github.com/Graylog2/graylog2-server/blob/0e027f2d07604805caa56ba7ba868cca810130a4/graylog2-server/src/main/java/org/graylog2/plugin/inputs/MessageInput.java#L133


(system) #6

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.