cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to delete Grail metric

Julius_Loman
DynaMight Legend
DynaMight Legend

How can a grail metric or Grail metric data points be deleted? The classic metrics can be deleted using the Classic Metric v2 API ( https://docs.dynatrace.com/docs/shortlink/api-metrics-v2-del-metric), but deleting them does not delete the Grail counterpart metric (speaking about metric created using OpenPipeline or ingestion).

Grail metrics can't be assigned to a bucket (so the bucket can be dropped), also you can't delete data from the default metric bucket or create a new metrics bucket. 

There is a record deletion API ( https://docs.dynatrace.com/docs/shortlink/record-deletion-in-grail ), however, it does not support metric data either.

Any ideas?

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner
4 REPLIES 4

I don't think this capability exists yet within the API, mainly because the raw metric data points are not accessible via any fetch command, which by extension places them beyond the reach of the current record deletion API. I haven't tried this, but it's worth trying whether the API will allow deletion of a metric series using a query like the below.

fetch metric.series
| filter startsWith(metric.key, "<Grail metric key here>")

If that doesn't work then I suspect that support/engineering would have to do this in the back-end on a case-by-case basis.

@marco_irmer no, unfortunately it can't be deleted:

{
  "error": {
    "code": 400,
    "message": "metric.series doesn't allow record deletion.",
    "errorDetails": []
  }
}

 

What happened and why this is needed: 

  • I have a metric based on business events, split by HTTP status
  • HTTP status is, wondering why, stored as Double which is automatically casted to string, however has a decimal point. See more here.
  • I converted it to long
  • This metric how has the same dimension with different types
  • This breaks visualizations since numeric dimension values can be used for legend ( @zietho FYI 😀, more on this here ). If you select a timeframe, your tiles lose the legend and it never comes back unless you edit the tiles. 
Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Hi @Julius_Loman,

I read through the links you posted and I would like to suggest a workaround for your issue with the different types in the dimension. In this query, there are two added commands.

1. fieldsAdd is used to override the existing dimension field so that all timeseries elements have the same format and type

2. summarize is used to re-summarize the timeseries events to actually group the data by the status dimension.

DQL:

data record(timestamp = toTimestamp("2025-03-17T08:30:00.000+0100"),status=200),
     record(timestamp = toTimestamp("2025-03-17T08:31:00.000+0100"),status=200),
     record(timestamp = toTimestamp("2025-03-17T08:32:00.000+0100"),status=500),
     record(timestamp = toTimestamp("2025-03-17T08:33:00.000+0100"),status="200"),
     record(timestamp = toTimestamp("2025-03-17T08:34:00.000+0100"),status=200),
     record(timestamp = toTimestamp("2025-03-17T08:34:00.000+0100"),status=200)
| makeTimeseries count = count(), 
    by:{status}
| fieldsAdd status = substring(toString(status),to:3) // take the first three characters
| summarize {takeFirst(timeframe), takeFirst(interval), takefirst(count)}, by: {status} // summarize again (being sure not to skip over any relevant fields/dimensions)

The query in its current form the above is limited to 'count' aggregations, but could probably be adapted for more complex use cases. I tested this query in a notebook and the legend worked fine for me.

Julius_Loman
DynaMight Legend
DynaMight Legend

Sure it's possible by using DQL directly, but not using explore metric. For non-DQL-savvy users, it's much straightforward to use metric explorer to display metrics. Suppose you have dozens of tiles across your dashboards. In that case, you have to redo them from scratch including visualization options as you can't convert the metric explorer source to DQL (DQL for the metric explorer is just displayed, you can't edit it).

Anyway deleting metrics by metric key is pretty much needed anyway.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Featured Posts