Skip to content

Commit a6be447

Browse files
martialblogmdicss
andauthoredJan 22, 2025··
Add link to Grafana panels (#50)
Add Links to grafana to every panel. So you can open the panel in grafana even if more than one panel of a dashboard is shown in icinga. With the link added to the title, you only can open the first shown pane Co-authored-by: mdicss <[email protected]>
1 parent aba0c33 commit a6be447

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php

+10
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,16 @@ public function getPreviewHtml(Model $object, $report = false)
464464
$res = $this->getMyPreviewHtml($serviceName, $hostName, $previewHtml);
465465

466466
if ($res) {
467+
// Add Link to Panel if the user has the permission
468+
if ($this->permission->hasPermission('grafana/showlink')) {
469+
$linkUrl = $url;
470+
$linkUrl = preg_replace('/(viewPanel=)[^&]+/', '${1}' . $panelid, $linkUrl);
471+
$textLink = new Link('View in Grafana', $linkUrl, ['target' => '_blank', 'class' => 'external-link']);
472+
$html->add($textLink);
473+
$iconLink = new Link(new Icon('arrow-up-right-from-square', ['title' => 'View in Grafana']), $linkUrl, ['target' => '_blank', 'class' => 'external-link']);
474+
$html->add($iconLink);
475+
}
476+
467477
$html->addHtml($previewHtml);
468478
}
469479

0 commit comments

Comments
 (0)
Please sign in to comment.