Skip to content

Instantly share code, notes, and snippets.

@jworl
jworl / yaml2json.sh
Created Jun 29, 2017
yaml2json function within bash
View yaml2json.sh
# requires PyYAML
_YAML2JSON(){
python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < $1
}
@jworl
jworl / es_index_property.sh
Created Aug 31, 2017
display elasticsearch index properties
View es_index_property.sh
index=$1
curl -XGET 'http://localhost:9200/${index}?pretty'
@jworl
jworl / es_delete_index.sh
Created Sep 1, 2017
Delete elasticsearch index
View es_delete_index.sh
INDEX=$1
curl -XDELETE http://localhost:9200/${INDEX}
View es_show_template.sh
TEMPLATE=$1
curl -XGET 'localhost:9200/_template/${TEMPLATE}?pretty'
@jworl
jworl / es_delete_by_query.sh
Last active Sep 7, 2017
elasticsearch delete by query
View es_delete_by_query.sh
ES_DELETE_QUERY(){
INDEX=$1
KEY=$2
VALUE=$3
curl -XPOST 'localhost:9200/${INDEX}/_delete_by_query?scroll_size=5000&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"${KEY}": "${VALUE}"
}
@jworl
jworl / logstash_template.sh
Last active Sep 14, 2017
elasticsearch template used by logstash for output
View logstash_template.sh
# Create logstash template for pipeline
LOGSTASH_TEMPLATE() {
pipeline=$1
curl -XPUT http://localhost:9200/_template/${pipeline}?pretty -H 'Content-Type: application/json' -d'
{
"order" : 0,
"version" : 50002,
"template" : "${pipeline}-*",
"settings" : {
"index" : {
@jworl
jworl / es_template_pfsense.sh
Last active Sep 14, 2017
create elasticsearch template used for pfsense logstash output
View es_template_pfsense.sh
curl -XPUT http://localhost:9200/_template/pfsense?pretty -H 'Content-Type: application/json' -d'
{
"order" : 0,
"version" : 50002,
"template" : "pfsense-*",
"settings" : {
"index" : {
"number_of_shards": 3,
"number_of_replicas": 1,
"refresh_interval" : "30s"
@jworl
jworl / es_indices.sh
Created Aug 31, 2017
show all elasticsearch indices with stats
View es_indices.sh
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
View prevent_rebalance.sh
# set the following cluster settings to prevent rebalancing
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
'
@jworl
jworl / cluster_rebalance.sh
Created Jan 8, 2018
global settings for cluster rebalance
View cluster_rebalance.sh
curl -XGET 'localhost:9200/_cluster/settings?pretty'
{
"persistent" : {
"cluster" : {
"routing" : {
"allocation" : {
"enable" : "all"
}
}
}