Elasticsearch With Wasabi
    • 03 Oct 2024
    • 3 Minutes to read
    • PDF

    Elasticsearch With Wasabi

    • PDF

    Article summary

    How do I use Elasticsearch with Wasabi?

    Elasticsearch has been validated for use with Wasabi. Follow instructions outlined below for more information.

    NOTE: We are running this on an Ubuntu 20.04 System in single-node mode. You will have to restart the Elasticsearch services after installing the "repository-s3" plugin. This procedure should be adjusted to your own cluster, and tested in a lab environment before attempting on a production system. In addition, if you are running a different OS you may need to adjust certain commands to fit your OS.

    Install HTTPie HTTP client for making local HTTP requests to Elasticsearch

    $ sudo snap install http

    Install the Elasticsearch repository-s3 plugin

    $ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install -b repository-s3

    Restart Elasticsearch Service to enable repository-s3 plugin

    $ sudo systemctl restart elasticsearch

    Validate plugin has been installed

    $ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin list

    Set Wasabi Environment Variables

    You will need to replace the access key, and secret key with keys generated from your Wasabi account. (This keypair combination has been revoked and will not work)

    Creating a Wasabi API Access Key Set

    $ WASABI_ACCESS_KEY=3E7H7DRC0I6Q4JGK6FGC
    $ WASABI_SECRET_KEY=ZqempHGBL5ZXmRyXGzF8DXd5nbj6n5GPX0gG9wv2+l3ych5dWhyKiM7EIkHOhzE=

    Load keys into Elasticsearch Keystore using the default client

    $ echo $WASABI_ACCESS_KEY | sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key
    $ echo $WASABI_SECRET_KEY | sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key

    Reload Elasticsearch Secure Settings

    $ http POST 127.0.0.1:9200/_nodes/reload_secure_settings

    Load repository configuration into Elasticsearch

    This is an example of the JSON required to configure Wasabi as an Object Storage Endpoint. You want to replace the bucket attribute with your bucket name, and the endpoint attribute with the appropriate URL for the Wasabi Region your bucket is located.

    {
      "type": "s3",
      "settings": {
        "bucket": "",
        "endpoint": ""
      }
    }

    Send request to Elasticsearch and create repository

    This takes your JSON request, and sends it in an HTTP PUT to the Elasticsearch server running on 127.0.0.1. The Request Path will be used to name the repository. In this example, the name of the repository is "my_wasabi_repository". You should name this according to your own naming conventions. You also want to update the bucket and endpoint attributes to match your Wasabi configuration.

    $ echo '{ "type":"s3","settings":{"bucket":"my-es-bucket","endpoint":"https://s3.wasabisys.com"}}' | http PUT 127.0.0.1:9200/_snapshot/my_wasabi_repository

    NOTE: That this example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in Service URLs for Wasabi's Storage Regions.

    Checked your indices if you only want to take a snapshot of certain indices

    This command will give you a list of indices if you want to take a snapshot of only a particular index to push to Wasabi.

    $ http 127.0.0.1:9200/_cat/indices?v=true

    The output will look like this

    HTTP/1.1 200 OK
    content-encoding: gzip
    content-length: 624
    content-type: text/plain; charset=UTF-8
    
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
    yellow open filebeat-7.10.2-2021.02.10-000001 Qk0GZpH3QJCss7z7n0fDxQ 1 1 0 0 208b 208b
    yellow open metricbeat-7.10.2-2021.02.10-000001 v6mk_95RRWa9lO7HG0OPtw 1 1 291 0 475.3kb 475.3kb
    green open .apm-custom-link kfr4lt2hQUuD6ZFwmEWjQA 1 0 0 0 208b 208b
    green open .kibana_task_manager_1 oFgmJ4zVQd2rmAgTFdoaJQ 1 0 5 2140 302.1kb 302.1kb
    yellow open filebeat-7.10.2-2021.02.10 rERopYJ1SMKS1YVHZgqjsw 1 1 69374 0 15mb 15mb
    green open .apm-agent-configuration eaiKkoekQkSuilh7e355kQ 1 0 0 0 208b 208b
    yellow open metricbeat-7.10.2-2021.02.10 GSo_oNpyQMyD5ceud1eCwg 1 1 61582 0 56.2mb 56.2mb
    green open .async-search OxG0O-3ISOK-XbHBWxZG6Q 1 0 0 0 3.7kb 3.7kb
    green open .kibana_1 FJAauGDmSzeiLw1JESY3gA 1 0 1101 18 2.5mb 2.5mb
    green open .kibana-event-log-7.10.2-000001 RX8Yqi5JRF-KANOd7GocRQ 1 0 2 0 11kb 11kb
    yellow open packetbeat-7.10.2-2021.02.10 qiaVu6SNRTSQCHvW8gvXQw 1 1 171524 0 46.6mb 46.6mb

    Taking Snapshots

    Take a snapshot of all of your indices

    This command will take a snapshot of all of your indices, and push them to "my_wasabi_repository". The name of the snapshot in this example is "full_snapshot_021021", you will want to rename this for your own naming conventions.

    $ http PUT 127.0.0.1:9200/_snapshot/my_wasabi_repository/full_snapshot_021021?wait_for_completion=true

    Take a snapshot of a certain index only

    $ echo '{"indices":"filebeat-*"}' | http PUT 127.0.0.1:9200/_snapshot/my_wasabi_repository/filebeat-021021?wait_for_completion=true

    Validate Snapshots

    You will need to update the name of the snapshot at the end of the path.

    $ http 127.0.0.1:9200/_snapshot/my_wasabi_repository/full_snapshot_021021