Prometheus custom exporter and usage

333 views
Skip to first unread message

kucko...@gmail.com

unread,
Mar 31, 2017, 2:01:51 AM3/31/17
to Prometheus Users
Hi,

I have come up with a custom exporter in GoLang. It simply listens to port 1234 and parse the json and add that to guage metrics and send it to port 8081.
When I execute the exporter , I am able to see the metrics in prometheus port 8081. But If I change the data in 1234, I cannot see the new value in prometheus. How can I make the exporter continuously poll the port 1234  and the send the result to port 8081.

Thanks,
Ambika

Björn Rabenstein

unread,
Apr 2, 2017, 1:29:29 PM4/2/17
to kucko...@gmail.com, Prometheus Users
I don't really understand what you are trying to do. The terminology
doesn't match:

- If your exporter is listening on port 1234, how can it poll port 1234?

- Prometheus is pull-based, so it would poll from port 8081 of your
exporter. The exporter would never "send" to port 8081 on its own, but
would wait for Prometheus to fetch metrics.

Have you read https://prometheus.io/docs/instrumenting/writing_exporters/ ?

--
Björn Rabenstein, Engineer
http://soundcloud.com/brabenstein

SoundCloud Ltd. | Rheinsberger Str. 76/77, 10115 Berlin, Germany
Managing Director: Alexander Ljung | Incorporated in England & Wales
with Company No. 6343600 | Local Branch Office | AG Charlottenburg |
HRB 110657B

bsi...@ncsu.edu

unread,
Jun 8, 2017, 10:32:14 AM6/8/17
to Prometheus Users, kucko...@gmail.com
I have been trying to do something like this. Can you please share your code?

Ionut Ilie

unread,
Jun 8, 2017, 12:28:29 PM6/8/17
to Prometheus Users, kucko...@gmail.com, bsi...@ncsu.edu
From what i understand when you post data on port 1234 it is not reflected on port 8081, so how do you load the data in the first place. ( file or http post )? 
if you share the code i can help.

@bsi: can you post the json, is not that hard to do.

Bhaskar Sinha

unread,
Jun 8, 2017, 1:19:42 PM6/8/17
to Ionut Ilie, Prometheus Users, kucko...@gmail.com
Hello,

The JSON I am using is :

 
   "process": 
      "maximumWaitTimeMS":-9223372036854775808,
      "totalResponseTimeMS":0,
      "maximumResponseTimeMS":-9223372036854775808,
      "minimumWaitTimeMS":9223372036854775807,
      "averageTimeMS":0,
      "totalWaitTimeMS":0,
      "lastResponseTimeMS":-1,
      "totalRequests":0,
      "averageWaitTimeMS":0,
      "minimumResponseTimeMS":9223372036854775807
   },
   "memory": 
      "usedMemory":448862416,
      "totalMemory":1005060096,
      "freeMemory":556197680,
      "maxMemory":3817865216
   }
}

Ionut Ilie

unread,
Jun 8, 2017, 2:44:43 PM6/8/17
to Prometheus Users, ionut....@gmail.com, kucko...@gmail.com, bsi...@ncsu.edu
this is mainly an example of post and convert, it is adapted after some exercises i did a while back.
i did not checked if the values are converted correctly, but i did check if the values are changed at the second post. :)

if you have any question, you can comment on either gist or here.

btw, the json looks very familiar.

cheers !

<script src="https://gist.github.com/ionutvilie/6ff915d19eaa3116b9b796463276c6dd.js"></script>

https://gist.github.com/ionutvilie/6ff915d19eaa3116b9b796463276c6dd
Reply all
Reply to author
Forward
0 new messages