Flow¶
grafanarmadillo.flow¶
Pieces for templating multiple dashboards at once.
- class grafanarmadillo.flow.Alert(name_obj: GrafanaPath | str | Path | List[str], name_tmpl: GrafanaPath | str | Path | List[str], templator: Templator)[source]¶
Flowable request for an Alert.
- class grafanarmadillo.flow.Dashboard(name_obj: GrafanaPath | str | Path | List[str], name_tmpl: GrafanaPath | str | Path | List[str], templator: Templator)[source]¶
Flowable request for a Dashboard.
- class grafanarmadillo.flow.FileStore(root: ~pathlib.Path, json_encoder: ~typing.Type[~json.encoder.JSONEncoder] = <class 'json.encoder.JSONEncoder'>, json_decoder: ~typing.Type[~json.decoder.JSONDecoder] = <class 'json.decoder.JSONDecoder'>)[source]¶
Store and retrieve Grafana objects in the filesystem.
Objects will be stored under the same path as in Grafana. For example, a dashboard titled “MyDashboard” in a folder titled “MyFolder” will appear at {root}/MyFolder/MyDashboard.json.
You can customise the path these files will be stored under. Override the method resolve_object_to_filepath.
- json_decoder¶
alias of
JSONDecoder
- json_encoder¶
alias of
JSONEncoder
- resolve_object_to_filepath(name: GrafanaPath | str | Path | List[str], type_: str)[source]¶
Find the file on disk that contains the object.
@param name: @param type_: The kind of object to find, one of “dashboard” or “alert”.
- class grafanarmadillo.flow.Flow(store_obj: ~grafanarmadillo.flow.Store, store_tmpl: ~grafanarmadillo.flow.Store, flows: ~typing.List[~grafanarmadillo.flow.Alert | ~grafanarmadillo.flow.Dashboard] = <class 'list'>)[source]¶
A collection of templating actions to do.
- flows¶
alias of
list
- obj_to_tmpl() FlowResult[source]¶
Import from the source to the destination.
- run(obj_to_tmpl: bool) FlowResult[source]¶
Run the flow.
- tmpl_to_obj() FlowResult[source]¶
Export from the destination to the source.
- exception grafanarmadillo.flow.FlowException(item: Alert | Dashboard, cause: BaseException | None = None)[source]¶
Wrapped Exception of running a Flow.
- class grafanarmadillo.flow.FlowResult(successes: List[Alert | Dashboard], failures: List[FlowException])[source]¶
Result of running a Flow.
- ensure_success() FlowResult[source]¶
Inline raise the first exception, if present.
- class grafanarmadillo.flow.GrafanaStore(gfn: GrafanaApi)[source]¶
Store and retrieve objects from a Grafana instance.
- class grafanarmadillo.flow.Store[source]¶
A destination or source for items.
- abstract read_alert(name: GrafanaPath | str | Path | List[str])[source]¶
Read an alert from this store.
- abstract read_dashboard(name: GrafanaPath | str | Path | List[str])[source]¶
Read a dashboard from this store.
- abstract write_alert(name: GrafanaPath | str | Path | List[str], alert)[source]¶
Write an alert to this store.
- abstract write_dashboard(name: GrafanaPath | str | Path | List[str], dashboard)[source]¶
Write an alert to this store.
- class grafanarmadillo.flow.URLStore[source]¶
Store and retrieve objects from remote URLs, such as https://grafana.com/grafana/dashboards/ or GitHub.