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

Fix Prometheus source JSON schema and generated resources CI job #952

Merged
merged 2 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- name: Run generating gRPC resources
run: make gen-grpc-resources
Expand Down
76 changes: 46 additions & 30 deletions internal/source/prometheus/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,44 +83,60 @@ func (p *Source) consumeAlerts(ctx context.Context, config Config, ch chan<- []b

func jsonSchema() api.JSONSchema {
return api.JSONSchema{
Value: heredoc.Docf(`{
Value: heredoc.Docf(`
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Prometheus",
"description": "%s",
"type": "object",
"properties": {
"url": {
"description": "Prometheus endpoint without api version and resource",
"url": {
"description": "Prometheus endpoint without api version and resource",
"type": "string",
"default": "http://localhost:9090"
},
"ignoreOldAlerts": {
"description": "If set as true, Prometheus source plugin will not send alerts that is created before plugin start time",
"type": "boolean",
"enum": [
"true",
"false"
],
"default": true
},
"alertStates": {
"description": "Only the alerts that have state provided in this config will be sent as notification. https://pkg.go.dev/github.com/prometheus/prometheus/rules#AlertState",
"type": "array",
"default": [
"firing",
"pending",
"inactive"
],
"enum": [
"firing",
"pending",
"inactive"
]
},
"log": {
"description": "Logging configuration",
"type": "object",
"properties": {
"level": {
"description": "Log level",
"type": "string",
"default": "http://localhost:9090",
},
"ignoreOldAlerts": {
"description": "If set as true, Prometheus source plugin will not send alerts that is created before plugin start time",
"type": "boolean",
"enum": ["true", "false"],
"default": true
},
"alertStates": {
"description": "Only the alerts that have state provided in this config will be sent as notification. https://pkg.go.dev/github.com/prometheus/prometheus/rules#AlertState",
"type": "array",
"default": ["firing", "pending", "inactive"]
"enum: ["firing", "pending", "inactive"]
},
"log": {
"description": "Logging configuration",
"type": "object",
"properties": {
"level": {
"description": "Log level",
"type": "string",
"default": "info",
"enum: ["info", "debug", "error"]
}
}
},
"default": "info",
"enum": [
"info",
"debug",
"error"
]
}
}
}
},
"required": []
}`, description),
}`, description),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/executor/executor.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/source/source.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.