Skip to content

Instantly share code, notes, and snippets.

@carsonip
Last active January 14, 2025 16:45
Show Gist options
  • Save carsonip/e892fd20319dbd211d8f026c54ab0435 to your computer and use it in GitHub Desktop.
Save carsonip/e892fd20319dbd211d8f026c54ab0435 to your computer and use it in GitHub Desktop.
Simple way to load a large log file (in GBs) into Elasticsearch
# alternative to elasticsearch_loader
# not optimized, as http connections are not reused
# but simple enough to work for files that are not prohibitively large
pv foo.log | split --line-bytes=10000000 --filter="cat | sed 's/^/{\"create\":{\"_index\":\"logs-foo-default\"}}\n/' | curl -u admin:changeme -XPOST -H 'Content-Type: application/x-ndjson' 'http://localhost:9200/_bulk' --data-binary @-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment