- Using Fling Gauge metrics
- Flink 1.17.x
- Added multiple Gauge metrics and updating the metrics on condition bases as shown in the code.
- Publishing messages to 2 different topics, expecting each topic should have an metrics
- Query Flink metric REST API and getting result for only one metrics not all
- Data not updating all the gauge metrics, only one metric updating.
- Why Gauge is updating only one metrics?
public class MyMapper extends RichFlatMapFunction<String, String> {
private transient Map<String, String> valueToExposeOne = new HashMap<String, String>;
private transient Map<String, String> valueToExposeTwo = new HashMap<String, String>;
@Override
public void open(Configuration config) {
getRuntimeContext().getMetricGroup().gauge("MyGaugeOne", new Gauge<Map<String, String>>() {
@Override
public Map<String, String> getValue() {
return valueToExposeOne
}
});
getRuntimeContext().getMetricGroup().gauge("MyGaugeTwo", new Gauge<Map<String, String>>() {
@Override
public Map<String, String> getValue() {
return valueToExposeTwo
}
});
}
@Override
public void flatMap(byte[] insptsrt, Collection col){
if(topic.equals("One")){
valueToExposeOne.put(key,value);
}
if(topic.equals("Two")){
valueToExposeTwo.put(key,value);
}
--------
}
}
REST API API for a job vertex."/jobs/:jobid/vertices/:vertexid/taskmanagers"
- When i hit the above API am seeing 2 metrics (MyGaugeOne and MyGaugeTwo), but only MyGaugeOne is having data not the other one
- added logs in my code (valueToExposeOne and valueToExposeTwo) is having data but in metrics only one metrics is having values.
Can any one suggest why Gauge not updating all the metricst? is there a way to check Gauge updating all the metrics or not? any code changes required?
Steps to reproduce the Issue
Create Flink Gauge metrics - MyGaugeOne and MyGaugeTwo for 2 diffent topics
Set individual Map value to each metrics
Bulild and deploy the flink applicaiton.
Invoke metrics REST API (/jobs/:jobid/vertices/:vertexid/metrics?get=0.Flat_Map_MyGaugeOne,0.Flat_Map_MyGaugeTwo)
Observe the REST API response, it shows only the frist topic metrics reslutl the other topic metrica always empty but we are setting values to both the mertrics. Not sure why multiple topic havin issue
[ { "id":"0.Flat_Map_MyGaugeOne", "value":"{key1=value1,key2=value2}" }, { "id":"0.Flat_Map_MyGaugeTwo", "value":{} } ]
- expected to return both the metrics values