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

provider a func to check rule file like rulefmt.ParseFile in prometheus #6641

Open
cruvie opened this issue Aug 24, 2023 · 3 comments
Open

Comments

@cruvie
Copy link

cruvie commented Aug 24, 2023

Is your proposal related to a problem?

I need to check a alert rule file, but when I use

import (
	"github.com/prometheus/prometheus/model/rulefmt"
	"testing"
)

func TestName(t *testing.T) {
	_, errors := rulefmt.ParseFile("./alerts1.rule")
	if errors != nil {
		t.Error(errors)
	}
}

error comes

[./alerts1.rule: yaml: unmarshal errors:
          line 1317: field partial_response_strategy not found in type rulefmt.RuleGroup]

it may relate to #1096 but I can only find a cmd tool.

Describe the solution you'd like

provider a func to check rule file like rulefmt.ParseFile in prometheus

@yeya24
Copy link
Contributor

yeya24 commented Aug 25, 2023

Why the CLI tool doesn't work for your usecase?
Or you can just follow https://github.com/thanos-io/thanos/blob/main/cmd/thanos/tools.go#L49C13-L49C13 and add your own function

@cruvie
Copy link
Author

cruvie commented Aug 25, 2023

Why the CLI tool doesn't work for your usecase? Or you can just follow https://github.com/thanos-io/thanos/blob/main/cmd/thanos/tools.go#L49C13-L49C13 and add your own function

I noticed the method, too, but I think if thanos changed prometheus' alert rule file, it should provider relate methods that prometheus contains like rulefmt.ParseFile

@yeya24
Copy link
Contributor

yeya24 commented Aug 25, 2023

@cruvie Feel free to contribute if you think this is necessary for your usecase.
It should be pretty straightforward using existing code & functions.

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

No branches or pull requests

2 participants