Skip to content

Instantly share code, notes, and snippets.

@Jo-Hue
Jo-Hue / freek-blog-part-1
Created September 11, 2019 13:56
freek-blog-part-1
#http.port: 9200
@Jo-Hue
Jo-Hue / query Elasticsearch on port 9200
Created September 11, 2019 14:00
query Elasticsearch on port 9200
# curl -i localhost:9200
HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Tue, 27 Aug 2019 14:09:48 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 493
Connection: keep-alive
{
"name" : "gametime-dev",
@Jo-Hue
Jo-Hue / Change the default site config
Created September 11, 2019 14:28
Change the default site config
server {
listen 9200;
location / {
proxy_pass http://localhost:9201;
}
}
@Jo-Hue
Jo-Hue / results in access log entries
Created September 11, 2019 14:35
results in access log entries
127.0.0.1 - - [27/Aug/2019:14:23:28 +0000] "GET /_nodes/_local?filter_path=nodes.*.settings.tribe HTTP/1.1" 200 2 "-" "-"
127.0.0.1 - - [27/Aug/2019:14:23:30 +0000] "HEAD / HTTP/1.1" 200 0 "-" "-"
127.0.0.1 - - [27/Aug/2019:14:23:30 +0000] "GET /_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip HTTP/1.1" 200 117 "-" "-"
@Jo-Hue
Jo-Hue / define our own log formats
Created September 11, 2019 14:36
define our own log formats
log_format upstream_time '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"'
' rt=$request_time uct=$upstream_connect_time uht=$upstream_header_time urt=$upstream_response_time';
@Jo-Hue
Jo-Hue / alter log format
Created September 11, 2019 14:38
alter log format
server {
listen 9200;
access_log /var/log/nginx/elasticsearch.access.upstream_time.log upstream_time;
location / {
proxy_pass http://localhost:9201;
}
}
@Jo-Hue
Jo-Hue / make another request
Created September 11, 2019 14:40
make another request
curl -s localhost:9200 -o /dev/null
tail -1 /var/log/nginx/elasticsearch.access.upstream_time.log
#=>
127.0.0.1 - - [27/Aug/2019:14:31:00 +0000] "GET / HTTP/1.1" 200 493 "-" "curl/7.58.0" rt=0.002 uct=0.000 uht=0.004 urt=0.004
@Jo-Hue
Jo-Hue / pipelines will now be installed
Created September 11, 2019 15:23
pipelines will now be installed
curl -s 'localhost:9200/_ingest/pipeline/*' | jq ' . | keys'
#=>
[
"filebeat-6.3.2-nginx-access-default",
"filebeat-6.3.2-nginx-error-pipeline"
]
@Jo-Hue
Jo-Hue / upstream_time log format
Created September 11, 2019 15:24
upstream_time log format
cat << EOF > pipeline.json
{
"description": "pipeline for parsing nginx response times",
"processors": [
{
"set": {
"field": "log_line",
"value": "{{message}}"
}
},
@Jo-Hue
Jo-Hue / add an input to the config
Created September 11, 2019 15:26
add an input to the config
- type: log
enabled: true
paths:
- /var/log/nginx/*upstream_time.log*
exclude_files: ['.gz$']
pipeline: nginx-response-time