diff --git a/htdocs/example_splunk.php b/htdocs/example_splunk.php new file mode 100644 index 0000000..b301de8 --- /dev/null +++ b/htdocs/example_splunk.php @@ -0,0 +1,26 @@ + array( + array( + 'type' => 'splunk', + 'query' => 'test query 1', + 'title' => 'Test Query 1
', + ), + array( + 'type' => 'splunk', + 'query' => 'test query 2', + 'title' => 'Test Query 2
', + ), + ), +); + +$tabs = Dashboard::$DEPLOY_TABS; +$tab_url = Dashboard::getTabUrl(__FILE__); + +include 'phplib/template.php'; diff --git a/htdocs/phplib/GraphFactory.php b/htdocs/phplib/GraphFactory.php index 94417e2..01f794e 100644 --- a/htdocs/phplib/GraphFactory.php +++ b/htdocs/phplib/GraphFactory.php @@ -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 ''; } diff --git a/htdocs/phplib/SplunkUtils.php b/htdocs/phplib/SplunkUtils.php index d260085..428d3ff 100644 --- a/htdocs/phplib/SplunkUtils.php +++ b/htdocs/phplib/SplunkUtils.php @@ -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"; } /** @@ -16,6 +16,6 @@ public static function splunkSearchUrl($query) { * @return string */ public static function htmlUrl($content, $link) { - return sprintf('%s', $link, $content); + return sprintf('%s', $link, $content); } }