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: validating prometheus target #1077

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

AleksandrMatsko
Copy link
Member

Changed the status code and returned description

Before this PR on any error from prometheus the response with status code 500 was returned.

Now if the error is caused by bad target the response with status code 400 is returned.

@AleksandrMatsko AleksandrMatsko requested a review from a team as a code owner August 30, 2024 09:33
api/handler/triggers.go Outdated Show resolved Hide resolved
api/handler/triggers.go Outdated Show resolved Hide resolved
almostinf
almostinf previously approved these changes Sep 3, 2024
api/handler/triggers.go Outdated Show resolved Hide resolved
@almostinf almostinf self-requested a review September 3, 2024 08:22
…metheus errors (except bad data error type)
almostinf
almostinf previously approved these changes Sep 10, 2024
@@ -9,6 +9,8 @@ import (
"strings"
"time"

prometheus "github.com/prometheus/client_golang/api/prometheus/v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А проверял как-то, что на выражениях, специфичных для виктории, ничего не поедет?

@AleksandrMatsko
Copy link
Member Author

/build

@AleksandrMatsko
Copy link
Member Author

/build

@AleksandrMatsko AleksandrMatsko marked this pull request as draft September 18, 2024 10:25
@AleksandrMatsko AleksandrMatsko marked this pull request as ready for review September 18, 2024 12:37
@AleksandrMatsko
Copy link
Member Author

/build

Copy link

Build and push Docker images with tag: fix-validating-prometheus-target.2024-09-20.edfaa20

2 similar comments
Copy link

Build and push Docker images with tag: fix-validating-prometheus-target.2024-09-20.edfaa20

Copy link

Build and push Docker images with tag: fix-validating-prometheus-target.2024-09-20.edfaa20

http.StatusForbidden: {},
}

if _, leadTo500 := codes4xxLeadTo500[statusCode]; statusCode/100 == 4 && !leadTo500 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statusCode/100 == 4 давай вынесем в функцию определяющую 400ый код + я бы все же переписал на statusCode >= 400 && statusCode < 500 просто из-за читаемости

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

Successfully merging this pull request may close these issues.

3 participants