Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collected metric ... was collected before with the same name and label values #636

Open
MrRothstein opened this issue Apr 14, 2022 · 4 comments
Labels
bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM

Comments

@MrRothstein
Copy link

I'm saw this error with rc48. It went away after restart, and when I looked at the source of the metric in question (from /json), I see two sources from the same program (lines 1 and 11). The program is 9 lines long... Is it possible reloading mtail using "kill -SIGHUP $(pidofproc $PROGNAME)" caused it to load the program twice somehow?

@jaqx0r
Copy link
Contributor

jaqx0r commented Apr 14, 2022 via email

@MrRothstein
Copy link
Author

MrRothstein commented Apr 14, 2022

I think I see what happened. The previous version of the program did declare the same variable on line 11. So, the following appears to have happened:

  1. A program declares a counter on line 11
  2. Metrics are generated with the counter
  3. A program is updated with a version where the counter is declared on line 1
  4. Mtail is reloaded, but metrics still include the counter sourced from line 11
  5. Metrics are generated with the counter on line 1
  6. Prometheus receives 500 response trying to scrape "metric ... was collected before with the same name and label values"

Not sure if this is correct or the expected behavior

@jaqx0r
Copy link
Contributor

jaqx0r commented Apr 14, 2022 via email

@MrRothstein
Copy link
Author

This fails (adds two metrics):

func TestSameMetricWithDifferentSourcePositions(t *testing.T) {
 expectedMetrics := 1
 s := NewStore()
 firstPositionMetric := NewMetric("foo", "prog", Counter, Int)
 firstPositionMetric.SetSource("some_source.mtail:1:9-50")
 _ = s.Add(firstPositionMetric)

 secondPositionMetric := NewMetric("foo", "prog", Counter, Int)
 secondPositionMetric.SetSource("some_source.mtail:2:9-50")
 _ = s.Add(secondPositionMetric)
 glog.Infof("Store: %v", s)
 if len(s.Metrics["foo"]) != expectedMetrics {
     t.Fatalf("should not add metric with different source position: %v", s)
 }
}

It looks like the dupe check is skipped for metrics where the sources are different, but the check does not differentiate between the program being different or only the position:

if v.Source != m.Source {

I don't see a "FromString" type function available for Position and I'm not completely sure if the source and position represent the same thing. If this is the issue, would it make sense to convert Source in Metric from string to Position and compare only the file name during the dupe check?

@jaqx0r jaqx0r added bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM labels Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM
Projects
None yet
Development

No branches or pull requests

2 participants