New annotation hooks

Our team at Caterpillar would like to request a couple of working examples for new annotation hooks.

As of now, the official docs cover an old annotationQuery method that has been marked as deprecated. We’d want to avoid using deprecated code, and have already spent a good chunk of time figuring out how the new API works. Without docs and relevant examples, this has become more challenging than expected.

When applying a new annotation range in graph panel, an old method exposes an object (of AnnotationQueryRequest<DataQuery> type) with certain params (such as range or rangeRow) we use when requesting our API server. With new hooks, it’s unclear where this data can be read from.

We’d be happy to learn any documentation you may have on the topic (be it completed or in draft).

Thanks in advance.

If you are creating your own datasource and want annotation support. The easiest thing is to add:

This is all that is required to use the standard QueryEditor and attach a mapping from normal results to annotations.

If you need custom UI/query processing for the queries check: grafana/annotations.ts at master · grafana/grafana · GitHub

Thanks for your suggestion. Will give it a try!