Expose alert information for environments
What does this MR do?
For the #214634 (closed) issue, backend needs to provide associated alerts information per environment. This MR extends the Internal API and GraphQL API to expose the alerts info, and later, frontend MR will actually consume these endopints for visualizing alert information in environment page. e.g.
Related #214634 (closed)
JSON schemas
/environments.json
This internal API endpoint is already existing and requested when a user opens an environment index page. The payload looks like:
{
"environments": [
{
"name": "production",
"size": 1,
"latest": {
"id": 27,
"name": "production",
"state": "available",
"environment_path": "/dosuken123/tidal-wave/-/environments/2060947",
...
"has_opened_alert": true // NEW. When there is an open alert for the latest environment, the key exists and contains `true` value. Otherwise, the key doesn't exist.
}
}
],
}
(e.g. http://local.gitlab.test:8181/shinya/tidal-wave/-/environments.json?scope=available&page=1&nested=true
)
Sample GraphQL query
query {
project(fullPath: "shinya/alert-dummy-test") { // Specify the project full path. This can be parsed from the current URL. Alternatively, backend can expose the attribute in the '/environments.json' payload above.
environment(name: "production") { // Specify the environment name. This is corresponding to `environments:latest:name` in the '/environments.json' payload above.
name
state
latestOpenedMostSevereAlert {
severity
title
detailsUrl
prometheusAlert {
humanizedText
}
}
}
}
}
Sample payload for the GraphQL query
{
"data": {
"project": {
"environment": {
"latestOpenedMostSevereAlert": {
"severity": "CRITICAL",
"title": "HTTP Error Rate",
"detailsUrl": "http://local.gitlab.test:8181/shinya/alert-dummy-test/-/alert_management/3/details",
"prometheusAlert": {
"humanizedText": "exceeded 0.1 %"
}
}
}
}
}
}
Process flow
You can see the process flow between frontend and backend in !38545 (closed).
Related #214634 (closed)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team