Re: [prometheus-users] Re: Prometheus file format

2023-08-08 Thread Moe
You're right I don't need the exact time when the metric is fetched. I only 
need it to differentiate between iterations within the batch job. Then is 
creating a separate metric the best way to go?

On Tuesday, August 8, 2023 at 4:09:24 AM UTC+5:30 Matt Doughty wrote:

> I just wanted to chime in to say that you almost never need to know
> exactly when a metric is updated.
> Before you start exporting additional timestamp metrics, you should
> really ask yourself whether you actually need them. What problem do
> they actually solve?
>
> --Matt
>
> On Mon, Aug 7, 2023 at 5:54 PM Stuart Clark  wrote:
> >
> > On 07/08/2023 21:00, Moe wrote:
> > > Thanks Brian that was really helpful,
> > >
> > > 2. The use case I want this for doesn't need continuous ingestion. In
> > > that case is there a way for me to add time stamp to 
> MetricFamilySample?
> >
> > That isn't how Prometheus works. It will scrape that metric every 10
> > seconds to 2 minutes. If you need to know when that set of metrics was
> > created a common pattern is to include a metric who's value is the
> > timestamp.
> >
> > --
> > Stuart Clark
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "Prometheus Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to prometheus-use...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/prometheus-users/d401af4d-8583-d2d6-dbbe-89853000e421%40Jahingo.com
> .
>
>
>
> -- 
> --Matt
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/bf01a491-2b12-4f10-b7db-fbf865647496n%40googlegroups.com.


[prometheus-users] Re: Prometheus file format

2023-08-07 Thread Moe
Thanks Brian that was really helpful,

2. The use case I want this for doesn't need continuous ingestion. In that 
case is there a way for me to add time stamp to MetricFamilySample? 

On Friday, August 4, 2023 at 12:54:12 AM UTC+5:30 Brian Candler wrote:

> 1. Either drop the file into a directory for the node_exporter textfile 
> collector; or put the file into a webserver directory, and scrape it from 
> Prometheus
>
> 2. The timestamp is the time that the metric was scraped by Prometheus
>
> Note that Prometheus isn't a general-purpose database, and although you 
> can ingest historical data via "backfilling 
> <https://prometheus.io/docs/prometheus/latest/storage/#backfilling-from-openmetrics-format>",
>  
> this isn't suitable for continuous ingestion. There is also the remote-write 
> protocol 
> <https://prometheus.io/docs/prometheus/latest/feature_flags/#remote-write-receiver>,
>  
> but that's not something that's easy to integrate with for regular users.
>
> A normal exporter works on-demand: that is, when it receives a HTTP 
> request it collects data as of that instant in time, and returns it in the 
> HTTP response. Rather than fight against Prometheus, I think it's better to 
> swim with the flow.
>
> On Thursday, 3 August 2023 at 18:37:25 UTC+1 Moe wrote:
>
>> Hey,
>>
>> I am using JMXCollector 
>> <https://github.com/prometheus/jmx_exporter/blob/main/collector/src/main/java/io/prometheus/jmx/JmxCollector.java>
>>  
>> to fetch metrics and writing it into a file using the TextFormat 
>> <https://github.com/prometheus/client_java/blob/98967b8367216f4107ad5621f260ed895c930262/simpleclient_common/src/main/java/io/prometheus/client/exporter/common/TextFormat.java#L66C27-L66C27>
>>  and 
>> the format looks like the sample below.
>>
>> # HELP kafka_server_socket_server_metrics_processor_queue_size_p99 
>>  
>> kafka.server:name=null,type=socket-server-metrics,attribute=processor-queue-size-p99
>> # TYPE kafka_server_socket_server_metrics_processor_queue_size_p99 untyped
>> kafka_server_socket_server_metrics_processor_queue_size_p99{listener="PLAINTEXT",}
>>  
>> 0.0
>>
>> I have two questions. 
>> 1. How do I load this file into Prometheus or grafana to visualise the 
>> metrics?
>> 2. The metrics do not have the time stamp in them at the end. How do I 
>> get the timestamp?
>>
>> Thanks in advance!
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/6bf06428-507b-4954-b8e3-4b4ae8cb879fn%40googlegroups.com.


[prometheus-users] Prometheus file format

2023-08-03 Thread Moe
Hey,

I am using JMXCollector 

 
to fetch metrics and writing it into a file using the TextFormat 

 and 
the format looks like the sample below.

# HELP kafka_server_socket_server_metrics_processor_queue_size_p99 
 
kafka.server:name=null,type=socket-server-metrics,attribute=processor-queue-size-p99
# TYPE kafka_server_socket_server_metrics_processor_queue_size_p99 untyped
kafka_server_socket_server_metrics_processor_queue_size_p99{listener="PLAINTEXT",}
 
0.0

I have two questions. 
1. How do I load this file into Prometheus or grafana to visualise the 
metrics?
2. The metrics do not have the time stamp in them at the end. How do I get 
the timestamp?

Thanks in advance!


-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/f13c53be-7ca4-429c-b208-9c78d10a2f14n%40googlegroups.com.


[prometheus-users] Re: How to use Prometheus' JMXCollector to collect metrics over multiple iterations

2023-07-25 Thread Moe
Oh, that makes sense. Also, does this mean the scraping interval logic 
resides in Prometheus?

On Tuesday, July 25, 2023 at 4:49:09 PM UTC+5:30 Doug Hoard wrote:

> Prometheus can be configured to scrape the JMX Exporter (or any other 
> Prometheus exposition (output) compliant URL.)
>
> On Tuesday, July 25, 2023 at 2:55:23 AM UTC-4 Moe wrote:
>
>> Thanks, Doug I'll look into using the Rest API output.
>>
>> Yeah, I would need access to List returned during 
>> collection.
>>
>> I see that the config file 
>> <https://github.com/prometheus/prometheus/blob/main/config/testdata/conf.good.yml>
>>  used 
>> in Prometheus has a scrape interval defined. Does this call the JMX 
>> collector?
>>
>> On Tuesday, July 25, 2023 at 5:46:40 AM UTC+5:30 Doug Hoard wrote:
>>
>>> I'm not aware of any code that performs what you are trying to 
>>> accomplish. Do you actually need access to the List 
>>> returned during the collection?
>>>
>>> Typically, a Java application would use the Prometheus JMX Exporter (as 
>>> a Java agent) to expose the metrics via HTTP(S). Your application could 
>>> start, pause for a specific period of time, then call the JMX Exporter REST 
>>> API on an interval (or for a specific number of iterations), capturing the 
>>> output, and parsing it.
>>>
>>> Here is a link to the Java class used to parse the REST API output used 
>>> by the integration tests:
>>>
>>>
>>> https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/MetricsParser.java
>>>
>>> On Monday, July 24, 2023 at 4:53:28 AM UTC-4 MUSTAJIB MOHAMMED KHAN 
>>> wrote:
>>>
>>>> I need to create a Java application which collects JMX metrics from a 
>>>> running java process. For this, I am using the JMXCollector 
>>>> <https://github.com/prometheus/jmx_exporter/blob/main/collector/src/main/java/io/prometheus/jmx/JmxCollector.java>
>>>>  class. 
>>>> I couldn't find the option in this to configure it for multiple iterations.
>>>>
>>>> I have a Java wrapper around this to schedule collection after a 
>>>> specified time and for a specified number of iterations. I would like to 
>>>> understand if there is an already existing class that I can use.
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/879167d2-f91f-48c8-82d1-3b587c0d045an%40googlegroups.com.


[prometheus-users] Re: How to use Prometheus' JMXCollector to collect metrics over multiple iterations

2023-07-25 Thread Moe
Thanks, Doug I'll look into using the Rest API output.

Yeah, I would need access to List returned during 
collection.

I see that the config file 

 used 
in Prometheus has a scrape interval defined. Does this call the JMX 
collector?

On Tuesday, July 25, 2023 at 5:46:40 AM UTC+5:30 Doug Hoard wrote:

> I'm not aware of any code that performs what you are trying to accomplish. 
> Do you actually need access to the List returned 
> during the collection?
>
> Typically, a Java application would use the Prometheus JMX Exporter (as a 
> Java agent) to expose the metrics via HTTP(S). Your application could 
> start, pause for a specific period of time, then call the JMX Exporter REST 
> API on an interval (or for a specific number of iterations), capturing the 
> output, and parsing it.
>
> Here is a link to the Java class used to parse the REST API output used by 
> the integration tests:
>
>
> https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/MetricsParser.java
>
> On Monday, July 24, 2023 at 4:53:28 AM UTC-4 MUSTAJIB MOHAMMED KHAN wrote:
>
>> I need to create a Java application which collects JMX metrics from a 
>> running java process. For this, I am using the JMXCollector 
>> 
>>  class. 
>> I couldn't find the option in this to configure it for multiple iterations.
>>
>> I have a Java wrapper around this to schedule collection after a 
>> specified time and for a specified number of iterations. I would like to 
>> understand if there is an already existing class that I can use.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/09bd5776-fff2-41ee-9ea3-8705120fac49n%40googlegroups.com.


[prometheus-users] Re: Prometheus Operator and auto discovery of AlertManagers

2020-04-01 Thread Richard Moe
Answering my own mail:)

Autodiscovery of AlertManagers is not supported in the Prom custom 
resource. It
requires a custom configuration.
https://github.com/coreos/prometheus-operator/blob/master/Documentation/custom-configuration.md

On Tuesday, March 31, 2020 at 3:54:10 PM UTC+2, Richard Moe wrote:
>
> Hi!
>
> I am struggling a bit to figure out how to correctly configure 
> autodiscovery of AlertManagers in a Kubernetes cluster.
>
> Anyone have a fully working example Prometheus custom resource of this?
>
> Just putting example config from Prometheus doc doesn't seem to work as 
> the resource
> expects a list of alertmanager endpoints (
> https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#alertmanagerendpoints
> )
>
> Example config not working:
>
> alerting:
>   alertmanagers:
>   - path_prefix: /admin/alertmanager
> kubernetes_sd_configs:
>   - role: pod
> tls_config:
>   ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
> bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
> relabel_configs:
> - source_labels: [__meta_kubernetes_pod_label_name]
>   regex: alertmanager
>   action: keep
> - source_labels: [__meta_kubernetes_namespace]
>   regex: default
>   action: keep
> - source_labels: [__meta_kubernetes_pod_container_port_number]
>   regex:
>   action: drop
>
>
>
> Thanks :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/da8108fb-f2fb-4ce4-ba34-e4b089c21106%40googlegroups.com.


[prometheus-users] Prometheus Operator and auto discovery of AlertManagers

2020-03-31 Thread Richard Moe
Hi!

I am struggling a bit to figure out how to correctly configure 
autodiscovery of AlertManagers in a Kubernetes cluster.

Anyone have a fully working example Prometheus custom resource of this?

Just putting example config from Prometheus doc doesn't seem to work as the 
resource
expects a list of alertmanager endpoints (
https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#alertmanagerendpoints
)

Example config not working:

alerting:
  alertmanagers:
  - path_prefix: /admin/alertmanager
kubernetes_sd_configs:
  - role: pod
tls_config:
  ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_name]
  regex: alertmanager
  action: keep
- source_labels: [__meta_kubernetes_namespace]
  regex: default
  action: keep
- source_labels: [__meta_kubernetes_pod_container_port_number]
  regex:
  action: drop



Thanks :)

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/96bbd5a2-2090-439d-84a3-853445ebd8d6%40googlegroups.com.