Skip to content

Instantly share code, notes, and snippets.

@rjosephwright
Created March 17, 2015 23:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjosephwright/4ed7d4d25f89f83875db to your computer and use it in GitHub Desktop.
Save rjosephwright/4ed7d4d25f89f83875db to your computer and use it in GitHub Desktop.
Kibana mapping
require 'json'
require 'net/http'
index_pattern = {
'index-pattern' => {
'properties' => {
'title' => {
'type' => 'string'
},
'timeFieldName' => {
'type' => 'string'
},
'intervalName' => {
'type' => 'string'
},
'customFormats' => {
'type' => 'string'
},
'fields' => {
'type' => 'string'
}
}
}
}
visualization = {
'visualization' => {
'properties' => {
'title' => {
'type' => 'string'
},
'visState' => {
'type' => 'string'
},
'description' => {
'type' => 'string'
},
'savedSearchId' => {
'type' => 'string'
},
'version' => {
'type' => 'integer'
},
'kibanaSavedObjectMeta' => {
'properties' => {
'searchSourceJSON' => {
'type' => 'string'
}
}
}
}
}
}
dashboard = {
'dashboard' => {
'properties' => {
'title' => {
'type' => 'string'
},
'hits' => {
'type' => 'integer'
},
'description' => {
'type' => 'string'
},
'panelsJSON' => {
'type' => 'string'
},
'version' => {
'type' => 'integer'
},
'kibanaSavedObjectMeta' => {
'properties' => {
'searchSourceJSON' => {
'type' => 'string'
}
}
}
}
}
}
search = {
'search' => {
'properties' => {
'title' => {
'type' => 'string'
},
'description' => {
'type' => 'string'
},
'hits' => {
'type' => 'integer'
},
'columns' => {
'type' => 'string'
},
'sort' => {
'type' => 'string'
},
'version' => {
'type' => 'integer'
},
'kibanaSavedObjectMeta' => {
'properties' => {
'searchSourceJSON' => {
'type' => 'string'
}
}
}
}
}
}
http = Net::HTTP.new('es.example.com', 9200)
http.send_request('PUT', '/.kibana')
http.send_request('PUT', '/.kibana/_mapping/index-pattern', index_pattern.to_json)
http.send_request('PUT', '/.kibana/_mapping/visualization', visualization.to_json)
http.send_request('PUT', '/.kibana/_mapping/dashboard', dashboard.to_json)
http.send_request('PUT', '/.kibana/_mapping/search', search.to_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment