Skip to content

Instantly share code, notes, and snippets.

@tegud
tegud / Index.js
Created December 22, 2014 18:38
Untangle Importer
var fs = require('fs');
var crypto = require('crypto');
function randomValueBase64 (len) {
return crypto.randomBytes(Math.ceil(len * 3 / 4))
.toString('base64') // convert to base64 format
.slice(0, len) // return required number of characters
.replace(/\+/g, '0') // replace '+' with '0'
.replace(/\//g, '0'); // replace '/' with '0'
}
[
{
"username": "selliott",
"firstName": "Steve",
"lastName": "Elliott",
"email": "[email protected]",
"password": "fgtdfgjgertu",
"javaClass": "com.untangle.uvm.LocalDirectoryUser",
"expirationTime": 0
}
[
{
"username": "selliott",
"firstName": "Steve",
"lastName": "Elliott",
"email": "[email protected]",
"password": "fgtdfgjgertu"
}
]
var fs = require('fs');
var crypto = require('crypto');
function randomValueBase64 (len) {
return crypto.randomBytes(Math.ceil(len * 3 / 4))
.toString('base64') // convert to base64 format
.slice(0, len) // return required number of characters
.replace(/\+/g, '0') // replace '+' with '0'
.replace(/\//g, '0'); // replace '/' with '0'
}
@tegud
tegud / translate-example.rb
Created January 25, 2015 11:13
Translate Plugin Example
filter {
translate {
regex => true
field => "url_page"
destination => "url_page_type"
fallback => "unknown"
dictionary => [
"\/((k[0-9]+_[a-zA-Z0-9\-\%'()]*)|(r[0-9]+_hotel[a-zA-Z0-9\-\%'()]*)|((H|h)otels(-p[0-9]+)?)|(AjaxSearch|Mobile(Ajax|Search)))\.aspx$", "search"
]
}
@tegud
tegud / grok-url.rb
Created January 25, 2015 11:39
Grok Url Example
filter {
grok { match => [ "url", "%{URIPATH:url_path}%{URIPARAM:url_querystring}?" ] }
}
@tegud
tegud / grok-url-2.rb
Created January 25, 2015 11:49
Grok regex example
filter {
grok {
match => [ "url_path", "^(?:\/(?<url_language>en|de|es|it|fr))?(?:\/p(?<url_partner>[0-9]+))?(?:\/pv(?<url_partner_value>[0-9a-zA-Z]+))?(?<url_page>.*)$" ]
}
}
@tegud
tegud / conditional-categorise.rb
Created January 25, 2015 15:07
Example of categorising urls via logstash conditionals
if [url_path] =~ /^\/status$/ {
mutate { add_tag => "health-check" }
} else if [url_path] =~ /^\/beacon\// {
mutate { add_tag => "beacon" }
} else {
mutate { add_tag => "content" }
}
@tegud
tegud / docker-compose-logstash-1.4.2.yml
Created August 28, 2015 15:36
Docker Compose file for Logstash 1.4.2
logstash:
image: pblittle/docker-logstash
volumes:
- ./logstash-config:/opt/logstash/conf.d/
- /var/log/logstash:/var/log/logstash
- ./geoip:/opt/logstash/vendor/geoip/
- ./ssl:/opt/ssl/
@tegud
tegud / Dockerfile
Created September 1, 2015 13:05
Basic Dockerfile
FROM logstash:1.5.3
RUN /opt/logstash/bin/plugin install logstash-filter-translate
RUN /opt/logstash/bin/plugin install logstash-filter-json_encode