Add read API for Alert Metric Images
What does this MR do and why?
API Request & responses
View images
Curl
curl --location --request GET 'http://gdk.test:3000/api/v4/projects/6/alert_management_alerts/12/metric_images' \
--header 'PRIVATE-TOKEN: glpat-DEpkrRZUMVgm6ixjRGCr'
Response
[
{
"id": 2,
"created_at": "2022-01-27T02:17:39.419Z",
"filename": "s7mnOhs.jpg",
"file_path": "http://gdk.test:3000/uploads/-/system/alert_management_metric_image/file/2/s7mnOhs.jpg",
"url": "http://gitlab.com",
"url_text": "Grafana metric"
},
{
"id": 3,
"created_at": "2022-01-27T02:18:24.055Z",
"filename": "s7mnOhs.jpg",
"file_path": "http://gdk.test:3000/uploads/-/system/alert_management_metric_image/file/3/s7mnOhs.jpg",
"url": "http://gitlab.com",
"url_text": "Grafana metric"
}
]
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
First create an alert:
- Navigate to
Settings > Monitor > Alerts > Current integrations
- Create & enable a new
HTTP Endpoint
alert integration if none exist - For an existing integration, click
> Send test alert
to trigger a test with a sample payload, like this one:{"title":"Triggering a test alert to associate with an incident"}
Then, create a metric image:
file = Rack::Test::UploadedFile.new('spec/fixtures/rails_sample.jpg', 'image/jpg')
alert = AlertManagement::Alert.last
alert.metric_images.create(file: file, url: 'http://www.gitlab.com', url_text: 'Example metric')
Then call the API using the example above.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #340852 (closed)
Edited by Sean Arnold