GithubHelp home page GithubHelp logo

Comments (8)

GiedriusS avatar GiedriusS commented on June 3, 2024

Is it the same if you specify the timestamp? How could we reproduce this?

from thanos.

MichaHoffmann avatar MichaHoffmann commented on June 3, 2024

FIWI: since subqueries ( even with same step ) are a very different construct, it is not unimaginable that they return different results. As for the dedup ~ i dont know whats happening here.

from thanos.

tizki avatar tizki commented on June 3, 2024

@GiedriusS I'm using a specific timestamp.
for me it reproduces any time on my environment. it's a counter metric that comes from 2 prometheus replicas.

@MichaHoffmann I tried to debug it a bit, I suspect it's something where the dedup choose which timestamps to use from the samples, but I got a little lost there.
if you can refer me to where to look, I can continue debugging. (or get some relevant info to post here)

from thanos.

tizki avatar tizki commented on June 3, 2024

found something interesting, if I do

my_metric{_label_0="service",_label_1="requests",_label_2="timer", server="server00102"}[5m]

without deduplication in a specific timestamp I get the following:
server1:

2583033 @1714665427.092
2588869 @1714665487.092
2594666 @1714665547.092
2600461 @1714665607.092
2606298 @1714665667.092

server2:

2583033 @1714665450.205
2588869 @1714665510.205
2594666 @1714665570.205
2600461 @1714665630.205
2606298 @1714665690.205

but when I do the same with deduplication, I get one more sample, the interval between the first to the second is much small (23 seconds) than the rest (60 seconds), and the diff in values is the 0, since the first sample and second are the same.

2583033 @1714665427.092
2583033 @1714665450.205 (23 seconds interval from previous, same value as previous)
2588869 @1714665510.205
2594666 @1714665570.205
2600461 @1714665630.205
2606298 @1714665690.205

it seems it takes the first from servers 1 and then the rest from server2.
now it clear why adding a step solves it (removes the duplicated sample).

any idea?

from thanos.

tizki avatar tizki commented on June 3, 2024

I managed to reproduce this use case in a unit test.
I added the following test case to TestDedupSeriesSet in dedup/iter_test.go:

{
			name:      "My Regression test",
			isCounter: true,
			input: []series{
				{
					lset: labels.Labels{{Name: "a", Value: "1"}},
					samples: []sample{
						{1714665427092, 2583033},
						{1714665487092, 2588869},
						{1714665547092, 2594666},
						{1714665607092, 2600461},
						{1714665667092, 2606298},
					},
				}, {
					lset: labels.Labels{{Name: "a", Value: "1"}},
					samples: []sample{
						{1714665450205, 2583033},
						{1714665510205, 2588869},
						{1714665570205, 2594666},
						{1714665630205, 2600461},
						{1714665690205, 2606298},
					},
				},
			},
			exp: []series{
				{
					lset:    labels.Labels{{Name: "a", Value: "1"}},
					samples: []sample{{1714665427092, 2583033}, {1714665487092, 2588869}, {1714665547092, 2594666}, {1714665607092, 2600461}, {1714665667092, 2606298}},
				},
			},
		},

The first sample doesn't get deduplicated and it takes the first samples from both sets.
I noticed that in dedup.iter.go Next() there is a usage in initial penalty for the first sample. the value of that penalty is 5000. If I increase that value to 23113, my test passes. anything lower and the test fails.

I'm not sure if it's the expected behavior

from thanos.

MichaHoffmann avatar MichaHoffmann commented on June 3, 2024

Thank you for the test and the debug work! Ill look into this over weekend

from thanos.

MichaHoffmann avatar MichaHoffmann commented on June 3, 2024

So, yeah; the scrape interval is large enough that the dedup algorithm thinks that the second sample of the first iterator is actually missing and that we need to fill with the second iterator from now on. This might be a bit hard to solve since we ( right now ) dont know the proper scrape interval apriori. I think we could maybe add a configurable flag like --deduplication.penalty-scrape-interval-hint=30s kinda flag to prime the deduplication algorithm that an initial gap of 30s does not constitute a missing sample and we can keep with the first iterator.

@GiedriusS @fpetkovski @yeya24 how does that sound?

from thanos.

tizki avatar tizki commented on June 3, 2024

perhaps I'm mixing, but shouldn't --query.default-step affect that penalty?
also, I might be able with a PR once there will be a design for the fix.

from thanos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.