questions of how to use prometheus

1,174 views
Skip to first unread message

georgia...@gmail.com

unread,
Aug 19, 2016, 8:25:52 PM8/19/16
to Prometheus Developers
Hi,
I'm New to Prometheus server, I have a couple questions regarding use prometheus.
1. I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.
2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
Could you let me know if prometheus has any interface which we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.
3. can I use push gateway to feed traffic data into prometheus? I have my local prometheus server running, I can see web page from http://localhost:9090
I downloaded ExamplePushGateway and modify as below, but after it run it throws out Exception in thread "main" java.io.IOException: Response code from http://localhost:9090/metrics/job/job was 404

Is there any extra step which I need to do? Could you let me know how to push data into prometheus database?

public class ExamplePushGateway {
static final CollectorRegistry pushRegistry = new CollectorRegistry();
static final Gauge g = (Gauge) Gauge.build().name("gauge").help("blah").register(pushRegistry);

/**
* Example of how to use the pushgateway, pass in the host:port of a pushgateway.
*/
public static void main(String[] args) throws Exception {
PushGateway pg = new PushGateway("localhost:9090" );
g.set(42);
pg.push(pushRegistry, "job");
}
}

Thanks and Regards,
Georgia

Brian Brazil

unread,
Aug 20, 2016, 3:54:10 AM8/20/16
to georgia...@gmail.com, Prometheus Developers
On 20 August 2016 at 01:25, <georgia...@gmail.com> wrote:
Hi,
I'm New to Prometheus server, I have a couple questions regarding use prometheus.
1.  I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.
2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
Could you let me know if prometheus has any interface which we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.

It sounds like you should use the SNMP exporter and get your dynamic discovery to write out a JSON file with the device locations for use by Prometheus. See http://www.robustperception.io/using-json-file-service-discovery-with-prometheus/
 
3. can I use push gateway to feed traffic data into prometheus?  I have my local prometheus server running, I can see web page from http://localhost:9090
I downloaded ExamplePushGateway and modify as below, but after it run it throws out Exception in thread "main" java.io.IOException: Response code from http://localhost:9090/metrics/job/job was 404

Is there any extra step which I need to do? Could you let me know how to push data into prometheus database?

public class ExamplePushGateway {
  static final CollectorRegistry pushRegistry = new CollectorRegistry();
  static final Gauge g = (Gauge) Gauge.build().name("gauge").help("blah").register(pushRegistry);

  /**
   * Example of how to use the pushgateway, pass in the host:port of a pushgateway.
   */
  public static void main(String[] args) throws Exception {
    PushGateway pg = new PushGateway("localhost:9090" );
    g.set(42);
    pg.push(pushRegistry, "job");
  }
}

The pushgateway runs on port 9091 by default, not 9090. The pushgateway is good for batch jobs, see https://prometheus.io/docs/practices/pushing/

--

Ben Kochie

unread,
Aug 20, 2016, 5:10:15 AM8/20/16
to georgia...@gmail.com, Prometheus Developers
On Sat, Aug 20, 2016 at 2:25 AM, <georgia...@gmail.com> wrote:
Hi,
I'm New to Prometheus server, I have a couple questions regarding use prometheus.
1.  I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.

Yes, we monitor all of our network gear with Prometheus using the snmp_exporter as a "proxy".  We collect most of our gear every 15 seconds, and some of our more powerful routers ever 5 seconds.  No need to wait 5min between polling with Prometheus.
 
2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
Could you let me know if prometheus has any interface which we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.

No, don't push, this is not recommended.  We keep our switch inventory in chef, and use chef to write out the list of targets into a discovery file for chef to collect[0]

 
3. can I use push gateway to feed traffic data into prometheus?  I have my local prometheus server running, I can see web page from http://localhost:9090
I downloaded ExamplePushGateway and modify as below, but after it run it throws out Exception in thread "main" java.io.IOException: Response code from http://localhost:9090/metrics/job/job was 404

Don't use the pushgateway.  It's not necessary for most monitoring tasks.
 
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

georgia...@gmail.com

unread,
Aug 20, 2016, 4:45:01 PM8/20/16
to Prometheus Developers, georgia...@gmail.com
On Saturday, August 20, 2016 at 12:54:10 AM UTC-7, Brian Brazil wrote:
> On 20 August 2016 at 01:25, <georgia...@gmail.com> wrote:
> Hi,
>
> I'm New to Prometheus server, I have a couple questions regarding use prometheus.
>
> 1.  I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.
>
> 2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
>
> Could you let me know if prometheus has any interface which we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.
>
>
>
> It sounds like you should use the SNMP exporter and get your dynamic discovery to write out a JSON file with the device locations for use by Prometheus. See http://www.robustperception.io/using-json-file-service-discovery-with-prometheus/
>  
Does SNMP exporter need to run in the switch side? Is it possible that I can run SNMP exporter in my local server which can connect to switch using SNMP library. Do you have any SNMP exporter Java example?

> 3. can I use push gateway to feed traffic data into prometheus?  I have my local prometheus server running, I can see web page from http://localhost:9090
>
> I downloaded ExamplePushGateway and modify as below, but after it run it throws out Exception in thread "main" java.io.IOException: Response code from http://localhost:9090/metrics/job/job was 404
>
>
>
> Is there any extra step which I need to do? Could you let me know how to push data into prometheus database?
>
>
>
> public class ExamplePushGateway {
>
>   static final CollectorRegistry pushRegistry = new CollectorRegistry();
>
>   static final Gauge g = (Gauge) Gauge.build().name("gauge").help("blah").register(pushRegistry);
>
>
>
>   /**
>
>    * Example of how to use the pushgateway, pass in the host:port of a pushgateway.
>
>    */
>
>   public static void main(String[] args) throws Exception {
>
>     PushGateway pg = new PushGateway("localhost:9090" );
>
>     g.set(42);
>
>     pg.push(pushRegistry, "job");
>
>   }
>
> }
>
>
>
> The pushgateway runs on port 9091 by default, not 9090. The pushgateway is good for batch jobs, see https://prometheus.io/docs/practices/pushing/

Thanks, after I update port to 9091, I got connection refused, see below. Did I miss any set up? I just download the latest prometheus and run it using default setting.

Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1169)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:933)
at io.prometheus.client.exporter.PushGateway.doRequest(PushGateway.java:257)
at io.prometheus.client.exporter.PushGateway.pushAdd(PushGateway.java:120)
at io.prometheus.client.exporter.ExamplePushGateway.main(ExamplePushGateway.java:18)


Thanks and Regards,
Georgia
>
> --
>
>
> Brian Brazil
> www.robustperception.io

georgia...@gmail.com

unread,
Aug 20, 2016, 4:54:35 PM8/20/16
to Prometheus Developers, georgia...@gmail.com
On Saturday, August 20, 2016 at 2:10:15 AM UTC-7, Ben Kochie wrote:
> On Sat, Aug 20, 2016 at 2:25 AM, <georgia...@gmail.com> wrote:
> Hi,
>
> I'm New to Prometheus server, I have a couple questions regarding use prometheus.
>
> 1.  I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.
>
>
>
> Yes, we monitor all of our network gear with Prometheus using the snmp_exporter as a "proxy".  We collect most of our gear every 15 seconds, and some of our more powerful routers ever 5 seconds.  No need to wait 5min between polling with Prometheus.

Do you have any SNMP exporter Java Example? I guess I'm still confusing about how snmp exporter works, I thought snmp exporter needs to run in the device side, if you can using snmp exporter as a "proxy", can you run snmp exporter in a separate centralized server and it can collect all the data from all switch/devices?

>  
> 2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
>
> Could you let me know if prometheus has any interface w/ich we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.
>
>
>
> No, don't push, this is not recommended.  We keep our switch inventory in chef, and use chef to write out the list of targets into a discovery file for chef to collect[0]
>
>
> [0]: https://prometheus.io/docs/operating/configuration/#<file_sd_config>

Do you have any detail example which shows how to setup and run those proxcy?
Thanks and Regards,
Georgia

>  
> 3. can I use push gateway to feed traffic data into prometheus?  I have my local prometheus server running, I can see web page from http://localhost:9090
>
> I downloaded ExamplePushGateway and modify as below, but after it run it throws out Exception in thread "main" java.io.IOException: Response code from http://localhost:9090/metrics/job/job was 404
>
>
>
> Don't use the pushgateway.  It's not necessary for most monitoring tasks.
>  
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.

Ben Kochie

unread,
Aug 21, 2016, 3:54:05 AM8/21/16
to georgia...@gmail.com, Prometheus Developers
On Sat, Aug 20, 2016 at 10:45 PM, <georgia...@gmail.com> wrote:
On Saturday, August 20, 2016 at 12:54:10 AM UTC-7, Brian Brazil wrote:
> On 20 August 2016 at 01:25,  <georgia...@gmail.com> wrote:
> Hi,
>
> I'm New to Prometheus server, I have a couple questions regarding use prometheus.
>
> 1.  I'm trying to figure out whether if Prometheus is a good fit for our current application. Basically we have a centralized Traffic Monitor(Java process) which pull traffic counter data across all the network switches using SNMP every five minute and save to local database. We are thinking if it's possible to save traffic data using Prometheus database instead of our local database.
>
> 2. It seems prometheus is also a time series database like Open TSDB which has http put mechanism to allow user to input metric data.
>
> Could you let me know if prometheus has any interface which we can push all the metric data every five minutes. By the way, it is not feasible for us to write SNMP exporter in all the network devices which can allow prometheus to scrape, since our application is dynamically discover the devices over the network.
>
>
>
> It sounds like you should use the SNMP exporter and get your dynamic discovery to write out a JSON file with the device locations for use by Prometheus. See http://www.robustperception.io/using-json-file-service-discovery-with-prometheus/
>  
Does SNMP exporter need to run in the switch side? Is it possible that I can run SNMP exporter in my local server which can connect to switch using SNMP library. Do you have any SNMP exporter Java example?

You can run the snmp_exporter anywhere that has access to the switch network.  For example many switch management networks are protected, so it's possible to run it from a bastion host. 

The snmp_exporter is written in python, it is stand-alone and requires no Java.

Please review the documentation: https://github.com/prometheus/snmp_exporter
Thanks and Regards,
Georgia
>
> --
>
>
> Brian Brazil
> www.robustperception.io

--

You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages