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

[Feature Request] Parsing response content of Non HTTP 200 response #874

Open
beirtipol opened this issue Jun 10, 2024 · 4 comments
Open

Comments

@beirtipol
Copy link

The Spring boot /acuator/health endpoint will return a 503 error code if any of the components it is monitoring report a status of DOWN. The response body still contains valid JSON, but infinity doesn't attempt to parse it, it just says 'No data'.

This should still work, regardless of the response code.

Here's some sample JSON

{
    "status": "UP",
    "components": {
        "clientConfigServer": {
            "status": "UP",
            "details": {
                "propertySources": [
                    "configserver:[email protected]:MyCompany/myapp-config.git/thisapp/thisapp-uat.yaml",
                    "configClient"
                ]
            }
        },
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 107317563392,
                "free": 24000552960,
                "threshold": 10485760,
                "path": "/application/.",
                "exists": true
            }
        },
        "someCustomCheck": {
            "status": "DOWN",
            "details": {
                "everything is": "awful"
            }
        },
        "livenessState": {
            "status": "UP"
        },
        "ping": {
            "status": "UP"
        },
        "readinessState": {
            "status": "UP"
        },
        "refreshScope": {
            "status": "UP"
        }
    },
    "groups": [
        "liveness",
        "readiness"
    ]
}
@yesoreyeram
Copy link
Collaborator

This is the expected behaviour of the plugin. How do you differentiate the 503 by the API error vs 503 of the underlying application health?

I would consider this as a feature request but not a bug.

@yesoreyeram yesoreyeram changed the title [Bug] Non-200 HTTP responses shouldn't stop infinity from working [Feature Request] Parsing response content of Non HTTP 200 response Jun 10, 2024
@yesoreyeram
Copy link
Collaborator

actually this piece of code considers anything greater than HTTP 400 as error.

if res.StatusCode >= http.StatusBadRequest {
return nil, res.StatusCode, duration, errors.New(res.Status)
}

We can accept something like ignoreHttpStatusCode: true in query then ignore http status codes in such cases

@beirtipol
Copy link
Author

beirtipol commented Jun 11, 2024 via email

@Houlistonm
Copy link

We have the same problem. Sadly, we're trying to use the same endpoint /actuator/health for two different purposes and the clients have different requirements.
The /actuator/health is scraped by:

  1. cloudfoundry foundation and the http response code is used to determine if the instance is health or not.
  2. grafana using the infinity data source to parse the payload to determine if the instance is healthy or not. unfortunately, the payload never gets read because of the 503 response when the i instance is unhealthy.

Spring boot does let us override the http response code (via configuration) to allow us to read the payload during an unhealthy state, but then the cloudfoundry will not replace the failed instance since the response code is not '503'

Is there a mechanism in the infinty data source to set a list of allowed http response codes via configuration (200, 503) so we can read the payload and take send alerts.

To be completely transparent, spring boot allows for the addition of code to expose the /actuator/health endpoint as a metric on the /actuator/prometheus endpoint for alerting, but that's just more code that has to be maintained by our development teams.

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

No branches or pull requests

3 participants