-1

I have implementation on java and Grafana/prometheus

From our java service we are ingesting payload to grafana and it plots

I have defined a Metric using java

public class MyPayloadService {

    
    private final AtomicInteger lastPayloadValue = new AtomicInteger(0);

    public MyPayloadService(MeterRegistry registry) {
        Gauge.builder("my.payload.value", this.lastPayloadValue, AtomicInteger::get)
            .description("The value from the most recently processed payload")
            .register(registry);
    }

    public void processPayload(int newPayloadValue) {
        this.lastPayloadValue.set(newPayloadValue);
        System.out.println("New payload value set to: " + newPayloadValue);
    }
}

Current it working with the same point is plotting again and again over a period of time

I am looking for something like if I ingest data1 in 12:00 and data2 12:30 in graph it should plot only once. something like in graph against 12:00 should be one point and 12:30 second point

but now its plotted again and again.

anyone can give suggestion may be using registry can we delete old one and keep only once.

4
  • How is the Gauge's data transported to Prometheus? Commented Oct 25 at 22:27
  • IIRC, the problem is that you're using a Gauge: it will report the last value set until it changes. It sounds like you want a Histogram instead. Commented Oct 27 at 9:48
  • This is expected behaviour for metrics in Prometheus. From the sounds of it, you don't really need metrics, but rather logs instead. Commented Oct 27 at 18:47
  • Any suggestions on how change code Commented Oct 29 at 0:07

1 Answer 1

0

I think you dislike getting a whole line while you only have distinct data points.

This is likely a feature of Grafana called Line interpolation. See configurable options here: https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/time-series/#line-interpolation

If you do not like that, maybe you need to switch to another kind of visualization.

Sign up to request clarification or add additional context in comments.

2 Comments

I mean plot in grafana chart as points only once as per the ingestion time. Not as lines
What have you tried so far that still does not satisfy your requirements? Please add such information to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.