Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Complete graph type splunk in the dashboard #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions htdocs/example_splunk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

// the title used for the page
$title = 'Splunk Example';

require_once 'phplib/Dashboard.php';

$graphs = array(
'splunk' => array(
array(
'type' => 'splunk',
'query' => 'test query 1',
'title' => 'Test Query 1<br>',
),
array(
'type' => 'splunk',
'query' => 'test query 2',
'title' => 'Test Query 2<br>',
),
),
);

$tabs = Dashboard::$DEPLOY_TABS;
$tab_url = Dashboard::getTabUrl(__FILE__);

include 'phplib/template.php';
4 changes: 4 additions & 0 deletions htdocs/phplib/GraphFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ public function getDashboardHTML($graph_config, $time = '1h', $show_deploys = tr
$g = new Graph_FITB($graph_time);
$g->addMetric($graph_config['host'], $graph_config['portname'], $graph_config['graphtype'], $graph_config['title']);
return $g->getDashboardHTML();
case 'splunk':
$g = new SplunkUtils();
$graph_url = SplunkUtils::splunkSearchUrl($graph_config['query'], $graph_time);
return $g->htmlUrl($graph_config['title'],$graph_url);
default:
return '';
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/phplib/SplunkUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class SplunkUtils {
* @param string $query
* @return string
*/
public static function splunkSearchUrl($query) {
public static function splunkSearchUrl($query, $time) {
global $splunk_server;
return "https://{$splunk_server}/en-US/app/search/flashtimeline?q=search " . urlencode(trim($query));
return "https://{$splunk_server}/en-US/app/search/flashtimeline?q=search " . urlencode(trim($query)) . "&earliest=-" . $time . "&latest=now";
}

/**
Expand All @@ -16,6 +16,6 @@ public static function splunkSearchUrl($query) {
* @return string
*/
public static function htmlUrl($content, $link) {
return sprintf('<a href="%s">%s</a>', $link, $content);
return sprintf('<a href="%s" target="_blank">%s</a>', $link, $content);
}
}