#elasticsearch Crash Course!
- A way to search... things
- A way to search your data in terms of natural language, and so much more
- A distributed version of lucene with a JSON API.
- A fancy clustered database
import { journey, step, monitor, expect } from '@elastic/synthetics'; | |
import { request } from 'playwright-core' | |
journey('My Example Journey', ({ page, params, context }) => { | |
// Only relevant for the push command to create | |
// monitors in Kibana | |
monitor.use({ | |
id: 'example-monitor', |
# Attempt to fix broken network in WSL2.0 | |
$guest_ip = bash -c "/sbin/ifconfig eth0 | egrep -o 'inet [0-9\.]+' | cut -d ' ' -f2" | |
Write-Output "Guest IP IS: $guest_ip" | |
$gateway_ips = Get-NetIPAddress -InterfaceAlias "vEthernet (WSL)" | select IPAddress | |
$gateway_ip = $gateway_ips[1].IPAddress | |
Write-Output "Gateway (local WSL adapter) IP is: $gateway_ip" | |
bash -c "sudo ifconfig eth0 netmask 255.255.240.0" | |
bash -c "sudo ip route add default via $gateway_ip" |
# Follow the instructions on https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/ | |
Then run | |
docker run --rm -it --user root --platform linux/arm64/v8 --entrypoint=/bin/bash -i docker.elastic.co/beats/elastic-agent:7.15.0-arm64 |
#!/bin/sh | |
split_cmd='cut -b 275,276,277,278,279 2002FemPreg.dat' | |
first_avg=`$split_cmd | grep '1 1$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'` | |
other_avg=`$split_cmd | grep -v ' 1$' | grep '1..$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'` | |
hours_diff=`echo "($first_avg-$other_avg)*168" | bc` | |
echo First borns: $first_avg weeks | |
echo Non-first borns: $other_avg weeks | |
echo Difference: $hours_diff hours |
# Count SLOC | |
export SLF=`mktemp -t cljsloc`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF |
# ElasticSearch upstart script | |
description "ElasticSearch service" | |
start on (net-device-up | |
and local-filesystems | |
and runlevel [2345]) | |
stop on runlevel [016] |
*filter | |
# Internal interfaces | |
-A INPUT -i lo -j ACCEPT | |
-A OUTPUT -o lo -j ACCEPT | |
#Allow all established traffic | |
-A INPUT -m state --state ESTABLISHED -j ACCEPT | |
#SSH |
filter { | |
ruby { | |
code => "io = StringIO.new(event.get('message')); enum = io.each_line; enum.next; event.set('mydate', enum.next); io.close" | |
} | |
} |
input { generator {} } | |
filter { | |
ruby { | |
# Add a \t (tab) by using its ASCII code (9) | |
code => 'event.set("message", 9.chr + event.get("message"))' | |
} | |
ruby { | |
# Make a new field with the tab removed | |
code => 'event.set("tabless", event.get("message").gsub(9.chr, ""))' |