Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
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
3 changes: 3 additions & 0 deletions config_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
* All other strings are interpretted via PHP's date formatting syntax.
* 'src_url': A server name for generating source links.
* Ex: 'https://localhost:5601'
*
* 'src_index_pattern_id': index pattern id to use in source links
*/

# Configuration for the 411 Alerts index.
Expand Down Expand Up @@ -129,6 +131,7 @@
'date_field' => '@timestamp',
'date_type' => null,
'src_url' => null,
'src_index_pattern_id' => null
],
];

Expand Down
21 changes: 17 additions & 4 deletions phplib/Search/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ protected function _getLink(Alert $alert) {

public function generateAlertLink($index, $type, $id) {
$cfg = $this->getConfig();
$index_pattern = $cfg['date_based'] ? \ESQuery\Util::generateKibanaPattern($cfg['index']):$cfg['index'];
return sprintf('%s/app/kibana#/doc/%s/%s/%s?%s', $cfg['src_url'], $index_pattern, $index, $type, http_build_query(['id' => $id]));

if($cfg['src_index_pattern_id']) {
$index_id = $cfg['src_index_pattern_id'];

} else {
$index_id = $cfg['date_based'] ? \ESQuery\Util::generateKibanaPattern($cfg['index']) : $cfg['index'];
}

return sprintf('%s/app/kibana#/doc/%s/%s/%s?%s', $cfg['src_url'], $index_id, $index, $type, http_build_query(['id' => $id]));
}

public function generateLink($query, $start, $end) {
Expand All @@ -47,10 +54,16 @@ public function generateLink($query, $start, $end) {
return null;
}

$index_pattern = $cfg['date_based'] ? \ESQuery\Util::generateKibanaPattern($cfg['index']):$cfg['index'];
if($cfg['src_index_pattern_id']) {
$index_id = $cfg['src_index_pattern_id'];

} else {
$index_id = $cfg['date_based'] ? \ESQuery\Util::generateKibanaPattern($cfg['index']) : $cfg['index'];
}

$parser = new \ESQuery\Parser;
try {
return $parser->generateUrl($query, $start, $end, $cfg['src_url'], $index_pattern);
return $parser->generateUrl($query, $start, $end, $cfg['src_url'], $index_id);
} catch(\ESQuery\Exception $e) {
return null;
}
Expand Down