mkf1
(Kasper)
October 3, 2022, 11:26am
1
Hi,
I have uploaded many sourcemaps to Kibana/APM at /api/apm/sourcemaps.
I know you can delete them using curl like it says here: RUM source map API | Kibana Guide [8.4] | Elastic
But is there anyway to delete all of them at the same time? Complete removal of all sourcemaps
Hi @mkf1 ,
Thanks for reaching out!
We don't have an endpoint to remove all sourcemaps at once.
You will need to do it programmatically. For example (node.js script):
const fs = require('fs')
const { request } = require('undici')
const auth = "ApiKey YOUR_API_KEY_HERE"
function getAllSourceMaps() {
return request('http://localhost:5601/api/apm/sourcemaps', {
headers: {
"kbn-xsrf": true,
Authorization: auth
}
})
.then(( { body }) => body.json())
}
async function removeAllSourceMaps() {
const { artifacts: sourceMaps } = await getAllSourceMaps()
for (const sourceMap of sourceMaps) {
await request(`http://localhost:5601/api/apm/sourcemaps/${sourceMap.id}`, {
method: 'DELETE',
headers: {
Authorization: auth,
"kbn-xsrf": true,
"content-type": "application/json"
}
})
}
}
removeAllSourceMaps()
.then(() => {
console.log("All sourcemaps have been removed")
})
.catch((err) => {
console.log("Something went wrong while removing sourcemaps", err)
})
Make sure you use your own API Key and that the endpoint points to your Kibana.
Let me know if this helps you.
Thanks,
Alberto
1 Like
system
(system)
Closed
October 25, 2022, 3:00am
4
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.