Skip to content
Permalink
Browse files

Merge pull request #1262 from mozilla/testing_kibanaurl

Fixup kibanaurl for cloudy mozdef setup
  • Loading branch information...
pwnbus committed May 15, 2019
2 parents 2f31e06 + 4dc9a02 commit 3e26a0b62c0cbecb4a46cfe6b1bcb647f710233c
@@ -86,7 +86,7 @@ Parameters:
AlertQueueUrl:
Type: String
Description: The url of the alert queue kombu should use for taskExchange.
Conditions:
Conditions:
OIDCEnabledCondition:
!Not [!Equals [!Ref OIDCClientId, Unset]]
OIDCNotEnabledCondition:
@@ -152,10 +152,11 @@ Resources:
# Drives the configuration of variables for a variety of containers.
OIDC_CLIENT_ID=${OIDCClientId}
OPTIONS_ESSERVERS=${ESURL}
# Private unauthed kibana url for accessing kibana API
OPTIONS_KIBANAURL=${KibanaURL}
# The OPTIONS_METEOR_KIBANAURL uses the reserved word "relative" which triggers MozDef
# to use relative links to Kibana : https://github.com/mozilla/MozDef/pull/956
OPTIONS_METEOR_KIBANAURL=https://relative:9090/_plugin/kibana/
OPTIONS_METEOR_KIBANAURL=http://relative:9090/_plugin/kibana/
OPTIONS_METEOR_ROOTURL=https://${DomainName}
METEOR_BACKEND=meteor:3000
ESBACKEND=${KibanaDomainOnlyURL}
@@ -1,5 +1,4 @@
[options]
kibanaurl=http://localhost:9090/app/kibana
esservers=http://elasticsearch:9200
mongohost=mongodb
mongoport=3002
@@ -17,7 +17,7 @@ if (Meteor.isClient) {

kibanaurl: function () {
var esmetadata = alerts.findOne({'esmetadata.id': Session.get('alertID')}).esmetadata;
url=getSetting('kibanaURL') + '#/doc/alerts-*/' + esmetadata.index + '/doc?id=' + esmetadata.id;
url=resolveKibanaURL(getSetting('kibanaURL')) + '#/doc/alerts-*/' + esmetadata.index + '/doc?id=' + esmetadata.id;
return url;
}
});
@@ -96,7 +96,7 @@
<tr class="alert-row">
<td>{{utctimestamp}}</td>
<td><a href="/alert/{{esmetadata.id}}">mozdef</a><br>
<a href="{{mozdef.kibanaURL}}#/doc/alerts-*/{{esmetadata.index}}/doc?id={{esmetadata.id}}" target="_blank">kibana</a>
<a href="{{ resolveKibanaURL mozdef.kibanaURL }}#/doc/alerts-*/{{esmetadata.index}}/doc?id={{esmetadata.id}}" target="_blank">kibana</a>
{{#if url}}
<br><a href="{{url}}" target ="_blank">docs</a>
{{/if}}
@@ -52,7 +52,7 @@ if (Meteor.isClient) {
Session.set('ipsearchipaddress',($(e.target).attr('data-ipaddress')));
var ipText=$(e.target).attr('data-ipaddress');
//console.log("IP: " + ipText)
var searchDomain=getSetting('kibanaURL');
var searchDomain=resolveKibanaURL(getSetting('kibanaURL'));
var searchPath="#/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-1h,mode:quick,to:now))&_a=(columns:!(_source),index:events-weekly,interval:auto,query:(query_string:(analyze_wildcard:!t,query:'details.sourceipaddress:"+ipText+"')),sort:!(utctimestamp,desc))";
var url=searchDomain+searchPath;
console.log("Opening url: " + url);
@@ -93,7 +93,7 @@

<template name="kibanaDashboardItem">
<li>
<a target=" _blank" href="{{url}}">{{name}}</a>
<a target=" _blank" href="{{ resolveKibanaURL mozdef.kibanaURL }}#/dashboard/{{id}}">{{name}}</a>
</li>
</template>

@@ -13,22 +13,6 @@ Template.menu.helpers( {
//subscription has records?
return features.find().count() > 0;
},
resolveKibanaURL: function( url ) {
// special function just for the menu
// to adjust the kibana URL if we are told to make it 'relative'
// to whatever DNS name we are running on
// i.e. pass in http://relative:9090/app/kibana
// when the running dns is something.com
// and we will set the hostname to something.com instead of 'relative'
var kibanaURL = new URL( url );
if ( kibanaURL.hostname == 'relative' ) {
// we were passed something like OPTIONS_METEOR_KIBANAURL=http://relative:9090/app/kibana
// so lets figure out where we should be
dnsURL = new URL( document.URL );
kibanaURL.hostname = dnsURL.hostname;
}
return kibanaURL;
},
// loads kibana dashboards
kibanadashboards: function() {
Meteor.call( 'loadKibanaDashboards' );
@@ -163,6 +163,10 @@ if ( Meteor.isClient ) {
return isFeature( featureName );
} );

UI.registerHelper( 'resolveKibanaURL', function(url){
return resolveKibanaURL(url);
});

UI.registerHelper( 'uiDateFormat', function( adate ) {
return dateFormat( adate );
} );
@@ -326,7 +330,7 @@ if ( Meteor.isClient ) {
anelement.children( '.hostname' ).each( function( index ) {
hosttext = $( this ).text();
$( this ).append( '<b></b>' );
var searchDomain = getSetting( 'kibanaURL' );
var searchDomain = resolveKibanaURL(getSetting( 'kibanaURL' ));
searchPath = "#/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-1h,mode:quick,to:now))&_a=(columns:!(_source),index:events-weekly,interval:auto,query:(query_string:(analyze_wildcard:!t,query:'hostname:" + hosttext + "')),sort:!(utctimestamp,desc))"
searchURL = searchDomain + searchPath;
$( this ).wrap( "<a href=" + searchURL + " target='_blank'></a>" );
@@ -30,3 +30,20 @@ isFeature = function( featureName ) {
return true;
}
};

resolveKibanaURL = function(url){
// special function just for the menu
// to adjust the kibana URL if we are told to make it 'relative'
// to whatever DNS name we are running on
// i.e. pass in http://relative:9090/app/kibana
// when the running dns is something.com
// and we will set the hostname to something.com instead of 'relative'
var kibanaURL = new URL(url);
if ( kibanaURL.hostname == 'relative' ){
// we were passed something like OPTIONS_METEOR_KIBANAURL=http://relative:9090/app/kibana
// so lets figure out where we should be
dnsURL=new URL(document.URL);
kibanaURL.hostname = dnsURL.hostname;
}
return kibanaURL;
};
@@ -1,5 +1,4 @@
[options]
kibanaurl=http://localhost:9090/app/kibana
esservers=http://localhost:9200
mongoport=3002
listen_host=0.0.0.0
@@ -527,11 +527,7 @@ def kibanaDashboards():
for dashboard in results['hits']:
resultsList.append({
'name': dashboard['_source']['title'],
'url': "%s#/%s/%s" % (
options.kibanaurl,
"dashboard",
dashboard['_id']
)
'id': dashboard['_id']
})

except ElasticsearchInvalidIndex as e:
@@ -627,9 +623,6 @@ def initConfig():
options.esservers = list(getConfig('esservers',
'http://localhost:9200',
options.configfile).split(','))
options.kibanaurl = getConfig('kibanaurl',
'http://localhost:9090',
options.configfile)

# mongo connectivity options
options.mongohost = getConfig('mongohost', 'localhost', options.configfile)
@@ -1,5 +1,4 @@
[options]
kibanaurl=http://localhost:9090/app/kibana
esservers=http://localhost:9200
mongoport=3002
listen_host=0.0.0.0
@@ -63,10 +63,10 @@ def test_route_endpoints(self):

json_resp.sort()

assert json_resp[1]['url'].endswith("/app/kibana#/dashboard/Example-SSH-Dashboard") is True
assert json_resp[1]['id'] == "Example-SSH-Dashboard"
assert json_resp[1]['name'] == 'Example SSH Dashboard'

assert json_resp[0]['url'].endswith("/app/kibana#/dashboard/Example-FTP-Dashboard") is True
assert json_resp[0]['id'] == "Example-FTP-Dashboard"
assert json_resp[0]['name'] == 'Example FTP Dashboard'


0 comments on commit 3e26a0b

Please sign in to comment.
You can’t perform that action at this time.