Table of Contents
- model
- APIEndpoints
- RequestsMethods
- APIModel
- DatasourceQuery
- DatasourceRuleQuery
- DatasourcePermission
- Alert
- AlertRuleQueryModelCondition
- AlertRuleQueryModel
- AlertQuery
- AlertRule
- EmbeddedContactPoint
- MatchType
- Matcher
- Route
- TimeRange
- TimeInterval
- MuteTimeInterval
- Silence
- AlertmanagerConfig
- AlertmanagerReceivers
- RulerRule
- UserObject
- PlaylistObject
- PlaylistItemObject
- TeamObject
- QueryDatasourceObject
- QueryObject
- CorrelationObject
- FindAnnotationObject
- AnnotationObject
- AnnotationGraphiteObject
- GlobalUser
- RolePermission
- CustomRole
- DatasourceCache
- PublicDashboard
- SSOSetting
- DashboardSchema
- Report
- ReportBrandingSettings
model
APIEndpoints Objects
class APIEndpoints(Enum)
The class includes all necessary API endpoint strings to connect the Grafana API
RequestsMethods Objects
class RequestsMethods(Enum)
The class includes all necessary method values to establish an HTTP/ HTTPS connection to the Grafana API endpoints
APIModel Objects
@dataclass
class APIModel()
The class includes all necessary variables to establish a connection to the Grafana API endpoints
Arguments:
host
str - Specify the host of the Grafana systemtoken
str - Specify the access token of the Grafana systemusername
str - Specify the username of the Grafana systempassword
str - Specify the password of the Grafana systemtimeout
float - Specify the timeout of the Grafana systemheaders
dict - Specify the headers of the Grafana systemhttp2_support
bool - Specify if you want to use HTTP/2ssl_context
ssl.SSLContext - Specify the custom ssl context of the Grafana systemnum_pools
int - Specify the number of the connection poolretries
any - Specify the number of the retries. Please use False as parameter to disable the retries
DatasourceQuery Objects
@dataclass
class DatasourceQuery()
The class includes all necessary variables to specify a query for the datasource search endpoint
Arguments:
datasource_id
int - Specify the id of the data sourceraw_sql
str - Specify the raw SQL string to search inside the Grafana systemref_id
str - Specify a reference id of the search command (default A)interval_ms
int - Specify the time interval in milliseconds of output format (default 1000)max_data_points
int - Specify maximum amount of data points that dashboard panel can render (default 100)output_format
str - Specify the output format of the query (default time_series)
DatasourceRuleQuery Objects
@dataclass
class DatasourceRuleQuery()
The class includes all necessary variables to specify a query for the datasource rule search endpoint
Arguments:
datasource_uid
str - Specify the uid of the data sourcemodel
dict - Specify the model of the search commandquery_type
str - Specify the query time of the search commandref_id
str - Specify a reference id of the search commandrelative_time_range
dict - Specify the related time range of the search command
DatasourcePermission Objects
@dataclass
class DatasourcePermission()
The class includes the necessary variables to generate a datasource permission object that is necessary to communicate with the Grafana datasource permissions endpoint
Arguments:
permission
Union[str, None] - Specify the datasource permission. Can be query, edit, admin or None. To remove a permission, set the permission value to None
Raises:
ValueError
- Missed specifying a necessary value
Returns:
permission
str - Returns the datasource permission
Alert Objects
@dataclass
class Alert()
The class includes all necessary variables to generate an alert object that is necessary to communicate with the Grafana alert endpoint
Arguments:
starts_at
str - Specify the start date of the alertends_at
str - Specify end date of the alertannotations
dict - Specify the annotations of the alertgenerator_url
str - Specify the url of the generator endpointlabels
dict - Specify labels of the alert
AlertRuleQueryModelCondition Objects
@dataclass
class AlertRuleQueryModelCondition()
The class includes all necessary variables to generate an alert rule query model condition object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
evaluator_params
list - Specify the evaluator parametersevaluator_type
str - Specify the evaluator typeoperator_type
str - Specify the operator typequery_params
list - Specify the query parametersreducer_params
list - Specify the reducer parametersreducer_type
str - Specify the reducer typetype
str - Specify the type
AlertRuleQueryModel Objects
@dataclass
class AlertRuleQueryModel()
The class includes all necessary variables to generate an alert rule query model object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
conditions
list - Specify the conditions list based on the AlertRuleQueryModelCondition objectsdatasource
dict - Specify the datasource dictionaryexpression
str - Specify the expression stringhide
bool - Specify the if the query should be hidedinterval_ms
int - Specify the interval in msmax_data_points
int - Specify the max data pointsref_id
str - Specify the unique identifier of the alert rule query modeltype
str - Specify the corresponding type
AlertQuery Objects
@dataclass
class AlertQuery()
The class includes all necessary variables to generate an alert query object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
datasource_uid
str - Specify the datasource uidmodel
AlertRuleQueryModel - Specify the model as AlertRuleQueryModelquery_type
str - Specify the query typeref_id
str - Specify the unique identifier of the alert queryrelative_time_range_from
int - Specify the relative from time rangerelative_time_range_to
int - Specify the relative to time range
AlertRule Objects
@dataclass
class AlertRule()
The class includes all necessary variables to generate an alert rule object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
condition
str - Specify the conditiondata
list - Specify the data as AlertQuery listexec_err_state
str - Specify the execution error statefolder_uid
str - Specify the folder uidno_data_state
str - Specify the no data stateorg_id
int - Specify the org idrule_group
str - Specify the rule group of the alert ruletitle
str - Specify the title of the alert ruleuid
str - Specify the uid of the alert rulefor_time
int - Specify the for duration as integerannotations
dict - Specify the annotations dictionary (default None)updated
str - Specify the updated date time as string (default None)provenance
str - Specify the provenance (default None)id
int - Specify the alert rule id (default 0)labels
dict - Specify the labels as dictionary (default None)
EmbeddedContactPoint Objects
@dataclass
class EmbeddedContactPoint()
The class includes all necessary variables to generate an embedded contact point object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
name
str - Specify the name of the embedded contact pointtype
str - Specify the type of the embedded contact pointsettings
dict - Specify the settings of the embedded contact pointdisable_resolve_message
bool - Specify if the resolve message should be disabled (default None)provenance
str - Specify the provenance (default None)uid
str - Specify the uid of the embedded contact point (default None)
MatchType Objects
class MatchType(Enum)
The class includes all necessary values to set the corresponding match type
Matcher Objects
@dataclass
class Matcher()
The class includes all necessary variables to generate an alert rule route matcher object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
name
str - Specify the name of the matchertype
MatchType - Specify the type of the matchervalue
str - Specify the value of the matcher
Route Objects
@dataclass
class Route()
The class includes all necessary variables to generate an alert rule route that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
continue_parameter
bool - Specify the continue parametergroup_by_str
List[str] - Specify the list of group by stringsreceiver
str - Specify the receiverprovenance
str - Specify the provenanceobject_matchers
List[Matcher] - Specify the list of object matchers (default None)group_interval
str - Specify the group time interval (default None)group_wait
str - Specify the group wait time (default None)repeat_interval
str - Specify the repeat interval (default None)routes
List[Route] - Specify the list of routes (default None)mute_time_intervals
List[str] - Specify the mute time interval as list (default None)
TimeRange Objects
@dataclass
class TimeRange()
The class includes all necessary variables to generate a time range object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
start_time
str - Specify the start time e.g. 14:00start_time
str - Specify the end time e.g. 15:00
TimeInterval Objects
@dataclass
class TimeInterval()
The class includes all necessary variables to generate a time interval object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
days_of_month
List[str] - Specify the days of month list (default None)months
List[str] - Specify the months list (default None)times
TimeRange - Specify the times list (default None)weekdays
List[str] - Specify the weekdays list (default None)years
List[str] - Specify the year range list (default None)
MuteTimeInterval Objects
@dataclass
class MuteTimeInterval()
The class includes all necessary variables to generate a mute time interval object that is necessary to communicate with the Grafana alert provisioning endpoint
Arguments:
name
str - Specify the name of the mute time interval.time_intervals
List[TimeInterval] - Specify the list of time interval objects
Silence Objects
@dataclass
class Silence()
The class includes all necessary variables to generate a silence object that is necessary to communicate with the Grafana silence endpoint
Arguments:
starts_at
str - Specify the start date of the silencecreated_by
str - Specify the name of the silence creatorends_at
str - Specify end date of the silencecomment
str - Specify a custom comment for the silenceid
str - Specify an id for the silencematchers
dict - Specify matchers for the silence
AlertmanagerConfig Objects
@dataclass
class AlertmanagerConfig()
The class includes all necessary variables to generate an Alertmanager config object that is necessary to communicate and set up the Grafana Alertmanager endpoint
Arguments:
global_config
dict - Specify the global config of the Alertmanagerinhibit_rules
list - Specify the inhibit rules of the Alertmanagermute_time_intervals
list - Specify the mute time intervals of the Alertmanagerreceivers
list - Specify the receiver's of the Alertmanagerroute
dict - Specify the route of the Alertmanagertemplates
list - Specify an Alertmanager template
AlertmanagerReceivers Objects
@dataclass
class AlertmanagerReceivers()
The class includes all necessary variables to generate an Alertmanager receiver's object that is necessary to communicate and set up the Grafana Alertmanager receivers endpoint
Arguments:
name
str - Specify the name of the receiveremail_configs
list - Specify the email configuration of the receiver'sgrafana_managed_receiver_configs
list - Specify the Grafana managed receiver configuration of the receiver'sopsgenie_configs
list - Specify the ops genie configuration of the receiver'spagerduty_configs
dict - Specify the pager duty configuration of the receiver'spushover_configs
list - Specify the push over configuration of the receiver'sslack_configs
list - Specify the Slack configuration of the receiver'svictorops_configs
list - Specify the victor ops configuration of the receiver'swebhook_configs
list - Specify the webhook configuration of the receiver'swechat_configs
list - Specify the wechaty configuration of the receiver's
RulerRule Objects
@dataclass
class RulerRule()
The class includes all necessary variables to generate a Ruler rule object that is necessary to communicate and set up a Grafana Ruler rule
Arguments:
alert
str - Specify the name of the ruleannotations
dict - Specify the annotations of the ruleexpr
str - Specify the expression of the rulegrafana_alert
dict - Specify the Grafana alert of the rulelabels
dict - Specify labels of the rulerecord
str - Specify recode value of the rulefor_id
int - Specify the id of the rule if you update an existing rule (default 0)
UserObject Objects
@dataclass
class UserObject()
The class includes all necessary variables to generate a User object that is necessary to update a Grafana User
Arguments:
email
str - Specify the name of the rulename
str - Specify the annotations of the rulelogin
str - Specify the expression of the ruletheme
str - Specify the Grafana alert of the rule
PlaylistObject Objects
@dataclass
class PlaylistObject()
The class includes all necessary variables to generate a playlist object
Arguments:
name
str - Specify the name of the playlistinterval
str - Specify the interval of the playlistitems
list - Specify a list of PlaylistItemObjects
PlaylistItemObject Objects
@dataclass
class PlaylistItemObject()
The class includes all necessary variables to generate a playlist item object that is necessary to update a playlist
Arguments:
type
str - Specify the type of the playlist itemvalue
str - Specify the value of the playlist itemorder
int - Specify the order of the playlist itemtitle
str - Specify the title of the playlist item
TeamObject Objects
@dataclass
class TeamObject()
The class includes all necessary variables to generate a team object that is necessary to create a team
Arguments:
name
str - Specify the name of the teamemail
str - Specify the email of the teamorg_id
int - Specify the org_id of the team
QueryDatasourceObject Objects
@dataclass
class QueryDatasourceObject()
The class includes all necessary variables to generate a query datasource object that is necessary to create a query history object
Arguments:
type
str - Specify the type of the datasource queryuid
str - Specify the uid of the datasource query
QueryObject Objects
@dataclass
class QueryObject()
The class includes all necessary variables to generate a query object that is necessary to create a query history
Arguments:
ref_id
str - Specify the ref_id of the query historykey
str - Specify the key of the query historyscenario_id
str - Specify the scenario_id of the query historydatasource
QueryDatasourceObject - Specify the datasource of the type QueryDatasourceObject
CorrelationObject Objects
@dataclass
class CorrelationObject()
The class includes all necessary variables to generate a find annotation object
Arguments:
source_datasource_uid
str - Specify the source datasource uid (default None)target_datasource_uid
str - Specify the target datasource uid (default None)label
str - Specify the label (default 100)description
str - Specify the description (default None)config_type
str - Specify the config type (default None)config_field
str - Specify the config field (default None)config_target
str - Specify the config target (default None)
FindAnnotationObject Objects
@dataclass
class FindAnnotationObject()
The class includes all necessary variables to generate a find annotation object
Arguments:
from_value
int - Specify the optional from value (default None)to_value
int - Specify the optional to value (default None)limit
int - Specify the optional limit (default 100)alert_id
int - Specify the optional alert id (default None)dashboard_id
int - Specify the optional dashboard id (default None)panel_id
int - Specify the optional panel_id (default None)user_id
int - Specify the optional user id (default None)type
str - Specify the optional type e.g. alert or annotation (default None)tags
list - Specify the optional tags (default None)
AnnotationObject Objects
@dataclass
class AnnotationObject()
The class includes all necessary variables to generate an annotation object
Arguments:
time
int - Specify the time as number in millisecondstime_end
int - Specify the end time as number in millisecondstags
list - Specify the organization annotation tags from a data source that are not connected specifically to a dashboard or paneltext
str - Specify the annotation description messagedashboard_uid
str - Specify the optional dashboard_uid (default None)panel_id
int - Specify the optional panel_id (default None)
AnnotationGraphiteObject Objects
@dataclass
class AnnotationGraphiteObject()
The class includes all necessary variables to generate a Graphite annotation object
Arguments:
what
str - Specify the event of the annotationtags
list - Specify the organization annotation tags from a data source that are not connected specifically to a dashboard or panelwhen
int - Specify the optional time as number in millisecondsdata
str - Specify the optional annotation description message
GlobalUser Objects
@dataclass
class GlobalUser()
The class includes all necessary variables to generate a global user object
Arguments:
name
str - Specify the name of the useremail
str - Specify the email of the userlogin
str - Specify the login type of the userpassword
str - Specify the password of the userorg_id
int - Specify the optional org id of the user (default None)
RolePermission Objects
@dataclass
class RolePermission()
The class includes all necessary variables to generate a role permission object
Arguments:
action
str - Specify the custom role action definitionscope
str - Specify the scope definition. If not present, no scope will be mapped to the permission (default None)
CustomRole Objects
@dataclass
class CustomRole()
The class includes all necessary variables to generate a custom role object
Arguments:
name
str - Specify the name of the roleuid
str - Specify the optional uid of the role (default None)global_role
bool - Specify the if the role is global or not. If set to False, the default org id of the authenticated user will be used from the request (default False)version
int - Specify the optional version of the role (default None)description
str - Specify the optional description of the role (default None)display_name
str - Specify the optional display_name of the role (default None)group
str - Specify the optional org group of the role (default None)hidden
bool - Specify whether the role is hidden or not. If set to True, then the role does not show in the role picker. It will not be listed by API endpoints unless explicitly specified (default False)permissions
list - Specify the optional permissions of the role as a list of the RolePermission objects (default None)
DatasourceCache Objects
@dataclass
class DatasourceCache()
The class includes all necessary variables to generate a datasource cache object
Arguments:
datasource_id
int - Specify the datasource iddatasource_uid
str - Specify the datasource uidenabled
bool - Specify if caching should be enabled for the datasourceuse_default_ttl
bool - Specify if the configured default TTL (Time-To-Live) should be used for both query and resource caching, instead of the user-specified valuesttl_queries_ms
int - Specify the TTL to use for query caching, in millisecondsttl_resources_ms
int - Specify the TTL to use for resource caching, in milliseconds
PublicDashboard Objects
@dataclass
class PublicDashboard()
The class includes all necessary variables to generate a public dashboard object
Arguments:
uid
str - Specify the optional unique identifier when creating a public dashboard. If it’s none, it will generate a new uid (default None)access_token
str - Specify the optional unique access token. If it’s none, it will generate a new access token (default None)time_selection_enabled
bool - Specify the optional enablement of the time picker inside the public dashboard (default False)is_enabled
bool - Specify the optional enablement of the public dashboard (default False)annotations_enabled
bool - Specify the optional enablement of the annotations inside the public dashboard (default False)share
str - Specify the optional share mode of the public dashboard (default public)
SSOSetting Objects
@dataclass
class SSOSetting()
The class includes all necessary variables to generate an SSO setting object
Arguments:
api_url
str - Specify the SSO api urlclient_id
str - Specify the SSO client idclient_secret
str - Specify the SSO client secretenabled
bool - Specify if the SSO provider is enabled or notscopes
str - Specify the SSO scopes
DashboardSchema Objects
@dataclass
class DashboardSchema()
The class includes all necessary variables to generate a dashboard schema object that is used for the reporting functionality
Arguments:
dashboard_uid
str - Specify the dashboard uidtime_range_from
str - Specify the dashboard time range fromtime_range_to
str - Specify the dashboard time range toreport_variables
dict - Specify the key-value pairs containing the template variables for this report, in dict format. If the value is None, the template variables from the reports dashboard will be used (default None)
Report Objects
@dataclass
class Report()
The class includes all necessary variables to generate a report object
Arguments:
name
str - Specify the name of the report that is used as an email subjectrecipients
str - Specify the comma-separated list of emails to which to send the report toreply_to
str - Specify the comma-separated list of emails used in a reply-to field of the report emailmessage
str - Specify the text message used for the body of the report emailstart_date
str - Specify the distribution starts from this dateend_date
str - Specify the distribution end from this datetime_zone
str - Specify the time zone used to schedule report executionorientation
str - Specify if the orientation should be portrait or landscapelayout
str - Specify if the layout should be grid or simpleenable_dashboard_url
str - Specify if the dashboard url should be added to the bottom of the report emaildashboards
List[DashboardSchema] - Specify the dashboards for which the reports should be generatedfrequency
str - Specify how often the report should be sent. Can be once, hourly, daily, weekly, monthly, last or custom. The value last schedules the report for the last day of the month. The value custom schedules the report to be sent on a custom interval. It requires interval_frequency and interval_amount to be specified e.g. every 2 weeks, where 2 is an interval_amount and weeks is an interval_frequency (default last)interval_frequency
str - Specify the type of the custom interval hours, days, weeks, months (default None)interval_amount
int - Specify the interval amount of the custom type (default 0)workdays_only
bool - Specify if the report only on Monday-Friday should be sent. Applicable to hourly and daily types of schedule (default None)formats
List[str] - Specify what kind of attachment to generate for the report. Available report formats are csv, pdf and image. The type csv attaches a CSV file for each table panel and the type image embeds an image of a dashboard into the emails body (default List["pdf"])
ReportBrandingSettings Objects
@dataclass
class ReportBrandingSettings()
The class includes all necessary variables to generate a report branding settings object
Arguments:
report_logo_url
str - Specify the url of an image used as a logo on every page of the reportemail_logo_url
str - Specify the url of an image used as a logo in the emailemail_footer_mode
str - Specify the email footer mode. Can be sent-by or none. The value sent-by adds a 'Sent by email footer text' footer link to the email. Requires specifying values in the email_footer_text and email_footer_link fields. The value none suppresses adding a 'Sent by' footer link to the emailemail_footer_text
str - Specify the text of a URL added to the email 'Sent by' footer (default None)email_footer_link
str - Specify the url address value added to the email 'Sent by' footer (default None)