Re: unable to find custom JMX metrics

2018-02-14 Thread Guozhang Wang
Salah,

I'm cross-posting my answer from SO here:

Looking at your code closely again, I realized you may forget to add the
metric into your sensor, i.e. you need to call
`sensorStartTs.add(metricName, MeasurableStat)` where `MeasurableStat`
defines the type of the stat, like Sum, Avg, Count, etc.
More specifically:

sensorStartTs = streamsMetrics.addSensor("start_ts",
Sensor.RecordingLevel.INFO );
sensorStartTs.add("my metric name", myStat);

This is because you used the general `addSensor` API to add the sensor; if
you used advanced `addThroughputSensor` etc it will call `sensor.add` for
you.

Then you should search for your metrics in the thread-level sensors, i.e.
in `stream-metrics`.

Guozhang

On Wed, Feb 14, 2018 at 1:14 PM, Matthias J. Sax 
wrote:

> Cross posted at SO:
> https://stackoverflow.com/questions/48745642/kstreams-streamsmetrics-
> recordthroughput-where-are-they-in-jconsole-adding-ow
>
>
>
> On 2/12/18 3:52 AM, Salah Alkawari wrote:
> > hi,
> > i have a processor that generates custom jmx metrics:
> > public class ProcessorJMX implements Processor {
> >
> > private StreamsMetrics streamsMetrics;
> > private Sensor sensorStartTs;
> >
> > @Override
> > public void init(ProcessorContext processorContext) {
> > streamsMetrics = processorContext.metrics();
> > sensorStartTs = streamsMetrics.addSensor("start_ts",
> Sensor.RecordingLevel.INFO);
> > }
> >
> > @Override
> > public void process(String key, GenericRecord val) {
> > streamsMetrics.recordThroughput(sensorStartTs,
> Long.valueOf(val.get("start_ts").toString()));
> > }
> >
> > @Override
> > public void punctuate(long l) { }
> >
> > @Override
> > public void close() { }
> > }i have this in my ProcessorSupplier - ProcessorSupplierJMX and use it
> like this:builder.stream(stringSerde, avroSerdeValue,
> topicOutput).process(new ProcessorSupplierJMX());
> > when i start my long running integration test, i goto jconsole, MBeans,
> kafka.streams - but i dont see this metric in any of the subfolder
> anywhere. what am i missing? am i looking in the wrong location? or do i
> need to activate something before i can see this metric?
> > Thanks,
> > Sal
> >
>
>


-- 
-- Guozhang


Re: unable to find custom JMX metrics

2018-02-14 Thread Matthias J. Sax
Cross posted at SO:
https://stackoverflow.com/questions/48745642/kstreams-streamsmetrics-recordthroughput-where-are-they-in-jconsole-adding-ow



On 2/12/18 3:52 AM, Salah Alkawari wrote:
> hi,
> i have a processor that generates custom jmx metrics:
> public class ProcessorJMX implements Processor {
> 
> private StreamsMetrics streamsMetrics;
> private Sensor sensorStartTs;
> 
> @Override
> public void init(ProcessorContext processorContext) {
> streamsMetrics = processorContext.metrics();
> sensorStartTs = streamsMetrics.addSensor("start_ts", 
> Sensor.RecordingLevel.INFO);
> }
> 
> @Override
> public void process(String key, GenericRecord val) {
> streamsMetrics.recordThroughput(sensorStartTs, 
> Long.valueOf(val.get("start_ts").toString()));
> }
> 
> @Override
> public void punctuate(long l) { }
> 
> @Override
> public void close() { }
> }i have this in my ProcessorSupplier - ProcessorSupplierJMX and use it like 
> this:builder.stream(stringSerde, avroSerdeValue, topicOutput).process(new 
> ProcessorSupplierJMX());
> when i start my long running integration test, i goto jconsole, MBeans, 
> kafka.streams - but i dont see this metric in any of the subfolder anywhere. 
> what am i missing? am i looking in the wrong location? or do i need to 
> activate something before i can see this metric?
> Thanks,
> Sal
> 



signature.asc
Description: OpenPGP digital signature