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

prom: Save __name__ before relabel for look up metric type #191

Merged
merged 3 commits into from
Mar 23, 2021

Conversation

pingleig
Copy link
Member

@pingleig pingleig commented Mar 22, 2021

Description of the issue

Fix #190

Description of changes

Save name before relabel using relabel.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  • manually
  • unit test
  • internal integ test

@pingleig pingleig requested a review from pxaws March 22, 2021 21:59
@pingleig pingleig changed the title prom: Save __name__ before relabel for look up metric type #190 prom: Save __name__ before relabel for look up metric type Mar 22, 2021
@pingleig
Copy link
Member Author

pingleig commented Mar 22, 2021

oops, it seems this breaks unit test

=== RUN   TestNewMetricsTypeHandler_HandleWithNormalTarget
2021/03/22 22:11:00 D! metric name changed from "" to "m3" during relabel
2021/03/22 22:11:00 E! metricsHandler NO metaData for m3 | instance1 | job1 
2021/03/22 22:11:00 E! metric_type ERROR: m3|job1|instance1|  
2021/03/22 22:11:00 D! metric name changed from "" to "m1" during relabel
2021/03/22 22:11:00 E! metricsHandler NO metaData for m1 | instance1 | job1 
2021/03/22 22:11:00 E! metric_type ERROR: m1|job1|instance1|  
2021/03/22 22:11:00 D! metric name changed from "" to "m2" during relabel
2021/03/22 22:11:00 E! metricsHandler NO metaData for m2 | instance1 | job1 
2021/03/22 22:11:00 E! metric_type ERROR: m2|job1|instance1|  
    metric_type_handler_test.go:220: 
        	Error Trace:	metric_type_handler_test.go:220
        	Error:      	Not equal: 
        	            	expected: 2
        	            	actual  : 0
        	Test:       	TestNewMetricsTypeHandler_HandleWithNormalTarget
--- FAIL: TestNewMetricsTypeHandler_HandleWithNormalTarget (0.00s)
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: index out of range [0] with length 0

goroutine 58 [running]:
testing.tRunner.func1.2(0x2bf1c80, 0xc0001a2180)
	/Users/runner/hostedtoolcache/go/1.16.2/x64/src/testing/testing.go:1144 +0x332
testing.tRunner.func1(0xc00023e780)
	/Users/runner/hostedtoolcache/go/1.16.2/x64/src/testing/testing.go:1147 +0x4b6
panic(0x2bf1c80, 0xc0001a2180)
	/Users/runner/hostedtoolcache/go/1.16.2/x64/src/runtime/panic.go:965 +0x1b9
github.com/aws/amazon-cloudwatch-agent/plugins/inputs/prometheus_scraper.TestNewMetricsTypeHandler_HandleWithNormalTarget(0xc00023e780)
	/Users/runner/work/amazon-cloudwatch-agent/amazon-cloudwatch-agent/amazon-cloudwatch-agent/plugins/inputs/prometheus_scraper/metric_type_handler_test.go:231 +0xaec
testing.tRunner(0xc00023e780, 0x2e2e730)
	/Users/runner/hostedtoolcache/go/1.16.2/x64/src/testing/testing.go:1194 +0xef
created by testing.(*T).Run
	/Users/runner/hostedtoolcache/go/1.16.2/x64/src/testing/testing.go:1239 +0x2b3
FAIL	github.com/aws/amazon-cloudwatch-agent/plugins/inputs/prometheus_scraper	0.469s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[prometheus] Relabel __name__ in metrics_relabel_config cause metric type error and dropped
2 participants