Skip to content

Instantly share code, notes, and snippets.

@bharath-elastic
Last active January 11, 2024 15:15
Show Gist options
  • Save bharath-elastic/c670cb5dadc1212a61e3f162083324a1 to your computer and use it in GitHub Desktop.
Save bharath-elastic/c670cb5dadc1212a61e3f162083324a1 to your computer and use it in GitHub Desktop.
def sc = doc['response.keyword'].value;
def m = ['200': 'OK', '404': 'Not Found', '503': 'Service Unavailable', '504': 'Gateway Timeout'];
if (m.containsKey(sc)) {
emit(m[sc])} else emit('none')
if(doc['agent.keyword'].value.contains('Firefox')) {
emit('Firefox')
} else if(doc['agent.keyword'].value.contains('MSIE')) {
emit('IE')
} else if(doc['agent.keyword'].value.contains('Chrome')) {
emit('Chrome')
} else if(doc['agent.keyword'].value.contains('Safari')) {
emit('Safari')
} else emit('Other')
def m = /.*(Chrome|Firefox|MSIE|Safari).*/.matcher(doc['agent.keyword'].value);
if (m.matches()) {
emit(m.group(1))
} else {
emit('Other')
}
def m = /.*(Chrome|Firefox|MSIE|Safari).*/.matcher(doc['agent.keyword'].value);
emit(m.matches() ? m.group(1) : "Other")
def s = [
'177.120.218.48',
'70.35.217.22',
'112.82.236.207',
'236.212.255.77',
'44.209.117.254',
'167.94.220.213',
'97.135.81.200'];
emit(s.contains(doc['clientip'].value) ? "Yes" : "No")
emit(doc['referer'].value.splitOnToken('/')[2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment