in otava/grafana.py [0:0]
def create_annotations(self, *annotations: Annotation):
"""
Reference:
- https://grafana.com/docs/grafana/latest/http_api/annotations/#create-annotation
"""
try:
url = f"{self.url}api/annotations"
for annotation in annotations:
data = asdict(annotation)
data["time"] = int(annotation.time.timestamp() * 1000)
del data["id"]
response = requests.post(url=url, json=data, auth=(self.__user, self.__password))
response.raise_for_status()
except HTTPError as err:
raise GrafanaError(str(err))