48
48
required: true
49
49
description:
50
50
- Text to be displayed in the annotation
51
+ dashboard_id:
52
+ required: false
53
+ description:
54
+ - The dashboard id where the annotation will be added
55
+ panel_id:
56
+ required: false
57
+ description:
58
+ - The panel id where the annotation will be added
51
59
'''
52
60
53
61
EXAMPLES = '''
@@ -179,14 +187,19 @@ def send_annotation(self, annotation):
179
187
180
188
class Annotation (object ):
181
189
182
- def __init__ (self , text , tags , tstamp = None , end_tstamp = None ):
190
+ def __init__ (self , text , tags , tstamp = None , end_tstamp = None ,
191
+ dashboard_id = None , panel_id = None ):
183
192
self .text = text
184
193
self .tags = tags
185
194
self ._set_time (tstamp )
186
195
self .isRegion = False
187
196
if end_tstamp :
188
197
self .timeEnd = int (end_tstamp ) * 1000
189
198
self .isRegion = True
199
+ if dashboard_id :
200
+ self .dashboardId = dashboard_id
201
+ if panel_id :
202
+ self .panelId = panel_id
190
203
191
204
def _set_time (self , tstamp = None , end_tstamp = None ):
192
205
if tstamp :
@@ -212,6 +225,8 @@ def main():
212
225
end_tstamp = dict (required = False , default = None , type = 'int' ),
213
226
tags = dict (required = False , default = [], type = 'list' ),
214
227
text = dict (required = True , type = 'str' ),
228
+ dashboard_id = dict (required = False , type = 'int' , default = None ),
229
+ panel_id = dict (required = False , type = 'int' , default = None )
215
230
)
216
231
module = AnsibleModule (
217
232
argument_spec = base_arg_spec ,
@@ -227,8 +242,11 @@ def main():
227
242
end_tstamp = module .params ['end_tstamp' ]
228
243
tags = ["ansible" ] + module .params ['tags' ]
229
244
text = module .params ['text' ]
245
+ dashboard_id = module .params ['dashboard_id' ]
246
+ panel_id = module .params ['panel_id' ]
230
247
231
- annotation = Annotation (text , tags , tstamp = tstamp , end_tstamp = end_tstamp )
248
+ annotation = Annotation (text , tags , tstamp = tstamp , end_tstamp = end_tstamp ,
249
+ dashboard_id = dashboard_id , panel_id = panel_id )
232
250
233
251
grafana = GrafanaManager (module , url , url_username , url_password , token )
234
252
0 commit comments