Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
TomonoriSoejima / json to csv.md
Last active October 27, 2021 07:31
json to csv.md
cat raw.response.from.kibana.json | jq .hits.hits[]._source > 1.json
jq -s < 1.json > 2.json
cat 2.json | jq '.[] + {"tags" : "_grokparsefailure_sysloginput"}' > 3.json
jq -s < 3.json > 4.json
cat 4.json | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > done.csv
@TomonoriSoejima
TomonoriSoejima / cat.md
Created February 25, 2021 06:13
cat.md
GET _cat/indices/?v&h=h,s,i,id,p,r,dc,dd,ss,creation.date.string&human=true
@TomonoriSoejima
TomonoriSoejima / version extract.md
Last active February 16, 2021 02:14
version extract.md
host="http://localhost:9200"
http --quiet get "$host/*/_settings?filter_path=*.settings.index.version&human" | jq -c 'to_entries[] | { index: {_index: "index_version_table", _type:"type"}}, .' |  http --quiet $host/_bulk

printf '{"query": "SELECT * FROM index_version_table"}' | http $host/_sql?format=txt | head

@TomonoriSoejima
TomonoriSoejima / push data to elastic cloud.md
Last active December 14, 2020 03:13
push data to elastic cloud.md
# get the deployment id and name.
# ecctl deployment list  | jq -r '.deployments[] | .id, .name'

short_deploymnent_id=$(echo $1|  cut -b -6)

credentials=$(find . | grep --color=never $short_deploymnent_id | xargs grep -v username | sed -e s/\,/\:/ -e s/,true//)

endpoint=$(ecctl deployment show $1 |  jq -r '.resources.elasticsearch[0].info.metadata | (.endpoint + ":" +  (.ports.https|tostring))')
@TomonoriSoejima
TomonoriSoejima / generator.conf.md
Created December 14, 2020 00:46
generator.conf.md
input {
    generator {
        count => 1
        add_field => {"call_start_time" => "2020-12-14T00:13:04.351Z"}
        add_field => {"call_end_time"   => "2020-12-14T00:15:04.351Z"}

    }
}
@TomonoriSoejima
TomonoriSoejima / sample.md
Created October 2, 2020 09:29
log4j for logstash
logger.dissectfilter.name = logstash.filters.dissect
logger.dissectfilter.level = error
logger.dissector.name = org.logstash.dissect.Dissector
logger.dissector.level = error
@TomonoriSoejima
TomonoriSoejima / ECEAnalyzer.md
Last active November 1, 2020 06:45
run ECEAnalyzer.jar faster
java -Deditor=code -jar ECEAnalyzer.jar $(ls -1 | grep --color=never ece_diag | grep -v tar.gz | tr '\n' ' ')
@TomonoriSoejima
TomonoriSoejima / request.md
Created September 8, 2020 14:26
list the user with top public gist counts
GET support/_search?size=30
{
  "_source": [
    "public_gists",
    "login",
    "name",
    "gists_url"
  ],
 "sort": [
@TomonoriSoejima
TomonoriSoejima / yum.md
Last active September 1, 2020 00:35
yum commands for 2020/8/31
sudo yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

# show the available version
yum list available logstash  --showduplicates

# install specific version
sudo yum -y install logstash-6.5.2-1
@TomonoriSoejima
TomonoriSoejima / random_jq_command.md
Last active November 6, 2020 12:29
random jq command.md

cat shards.json | jq -r '.[] | select(.index | contains("2019")) | .index, .store' | paste - - all.txt | sort -k 2 -nr | cat -n