Skip to content

Instantly share code, notes, and snippets.

@walidum
Created September 3, 2021 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walidum/56acf44ffec5cb9b01e99693aa6fe599 to your computer and use it in GitHub Desktop.
Save walidum/56acf44ffec5cb9b01e99693aa6fe599 to your computer and use it in GitHub Desktop.
flattened and exception mappings management in elasticsearch
1.
curl -XPUT "http://127.0.0.1:9200/demo-default/_doc/1" -d'{
"message": "[5592:1:0309/123054.737712:ERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.",
"fileset": {
"name": "syslog"
},
"process": {
"name": "org.gnome.Shell.desktop",
"pid": 3383
},
"@timestamp": "2020-03-09T18:00:54.000+05:30",
"host": {
"hostname": "bionic",
"name": "bionic"
}
}'
2.
curl -XGET "http://127.0.0.1:9200/demo-default/_mapping?pretty=true"
3.
curl -XGET "http://127.0.0.1:9200/_cluster/state?pretty=true" >> es-cluster-state.json
4.
curl -XPUT "http://127.0.0.1:9200/demo-flattened"
5.
curl -XPUT "http://127.0.0.1:9200/demo-flattened/_mapping" -d'{
"properties": {
"host": {
"type": "flattened"
}
}
}'
6.
curl -XPUT "http://127.0.0.1:9200/demo-flattened/_doc/1" -d'{
"message": "[5592:1:0309/123054.737712:ERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.",
"fileset": {
"name": "syslog"
},
"process": {
"name": "org.gnome.Shell.desktop",
"pid": 3383
},
"@timestamp": "2020-03-09T18:00:54.000+05:30",
"host": {
"hostname": "bionic",
"name": "bionic"
}
}'
7.
curl -XGET "http://127.0.0.1:9200/demo-flattened/_mapping?pretty=true"
8.
curl -XPOST "http://127.0.0.1:9200/demo-flattened/_update/1" -d'{
"doc" : {
"host" : {
"osVersion": "Bionic Beaver",
"osArchitecture":"x86_64"
}
}
}'
9.
curl -XGET "http://127.0.0.1:9200/demo-flattened/_search?pretty=true" -d'{
"query": {
"term": {
"host": "Bionic Beaver"
}
}
}'
10.
curl -XGET "http://127.0.0.1:9200/demo-flattened/_search?pretty=true" -d'{
"query": {
"term": {
"host.osVersion": "Bionic Beaver"
}
}
}'
11.
curl -XGET "http://127.0.0.1:9200/demo-flattened/_search?pretty=true" -d'{
"query": {
"term": {
"host.osVersion": "Beaver"
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment