Skip to content

Instantly share code, notes, and snippets.

View renshuki's full-sized avatar
💭
🇫🇷 🇯🇵 🇺🇸

Francois-Clement Brossard renshuki

💭
🇫🇷 🇯🇵 🇺🇸
View GitHub Profile
@renshuki
renshuki / latency-of-curl-command.md
Created February 28, 2020 01:51
How to retrieve latency of a cURL command
curl -o /dev/null -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n'  https://your_endpoint_url:port
@renshuki
renshuki / kibana-how-to-set-max-memory.md
Created February 13, 2020 09:00
Kibana - How to set instance max memory / heap (NodeJS)

You'll need to set NODE_OPTIONS in your environment variables.

export NODE_OPTIONS="--max-old-space-size=2048"

(which equivalent to 2GB for example)

Please note a Kibana restart is needed

@renshuki
renshuki / logstash-split-csv-columns-multiple-events.md
Last active January 24, 2020 07:40
Logstash pipeline configuration - split CSV columns into multiple events

CSV Sample

col1,col2,col3
0,1,2
3,4,5
6,7,8

Code

@renshuki
renshuki / elasticsearch-bulk-index-from-json-hits.md
Last active March 4, 2024 13:23
Elasticsearch - Bulk index from a JSON file hits (with jq)
cat file.json | jq -c '.hits.hits[] | { index: {_index:._index, _type:._type, _id:._id}}, ._source' | curl -XPOST -H "Content-Type: application/x-ndjson" localhost:9200/_bulk --data-binary @- | jq .
@renshuki
renshuki / elasticsearch-return-json-output-single-existing-field.md
Created November 11, 2019 07:41
Elasticsearch - Return JSON output with a single existing field
GET .monitoring-es*/_search
{
  "_source": ["node_stats.process.cpu.percent"],
  "size": 200,
  "query": {
   "exists": {
     "field": "node_stats.process.cpu.percent"
   }
 }
@renshuki
renshuki / painless_script_compare_current_date_with_index_date.md
Created October 16, 2019 08:57
Elasticsearch - Painless script to compare the current date with a date already indexed into a document

Elasticsearch Painless script which aims to calculate the difference in days between a date indexed into a document and the current date.

GET days_compare/_search
{
  "script_fields": {
    "diffdate": {
      "script": {
        "lang":   "painless",
 "source": """
@renshuki
renshuki / configuration_lowercase_tokenizer_example.md
Last active October 15, 2019 05:36
Elasticsearch - Configuration example of lowercase tokenizer for an index
PUT my_lowercase_tokenizer/
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_custom_analyzer": {
          "tokenizer": "lowercase"
        }
 }
@renshuki
renshuki / kibana_scripted_field_conditional_value_check.md
Created October 2, 2019 02:40
Kibana scripted field conditional check for values not empty
if (doc['field'].size() != 0) { 
 // Do what operation you need
}
@renshuki
renshuki / elasticsearch_filedatavisualizer_geopoint_ingest_pipeline_conversion.md
Created September 27, 2019 11:05
Elasticsearch CSV import via File Data Visualizer (ML) - Convert latitude and longitude column to geo_point using ingest pipeline
  1. Choose your CSV file to import including your coordinates data and upload it

location.csv

lat,long, timestamp
41.12,-71.34,1569476964
38.85896,-106.01665,1569476964
65.47629,18.61576,1569476964
@renshuki
renshuki / elasticsearch.service
Created July 17, 2019 10:12
Elasticsearch 7.x Systemd startup script
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
RuntimeDirectory=elasticsearch
PrivateTmp=true
Environment=ES_HOME=/usr/share/elasticsearch