cURL commands on Windows

How exactly does one go about using cURL commands on Windows to manipulate Elasticsearch? What are the prerequisite installations required in order to use them? Could someone please guide me through this process?

You don't have to use curl. It's just a HTTP client. On Windows I'd use Fiddler, Postman or similar instead.

Hey, I just discovered the wonderfully convenient Sense extension on the Chrome browser that does this very neatly. It takes cURL commands as the input and converts them to the required JSON files and indexes/searches accordingly.

Any idea how I can index multiple documents into ElasticSearch all at one go using these HTTP clients? That's the one leap I must take to complete my project.

Thanks in advance!

Yes, Sense is a good choice. Look into the bulk API for indexing multiple documents per request.

Any idea how I could bulk-index directly from a file containing the logs?

Use Logstash.

Instead of using curl, if you have Powershell installed, you can use the Invoke-RestMethod cmdlet:

Invoke-RestMethod -Uri 'http://1.2.3.4:9200/_search' -Method 'POST' -Body '
{
  "query": {
    "match_all": { }
  }
}'
1 Like

Hi I am new on ELK,
Do you how I can do a cmdlet like :
curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -H "Content-Type: application/json" -d '{
"password" : "elasticpassword"
}'

on PowerShell please ?

Regards
Vinuja

The equivalent in PowerShell would be something like

$username = "elastic"
$currentPassword = "changeme"
$newPassword = "elasticpassword"
$bytes = [Text.Encoding]::UTF8.GetBytes(("{0}:{1}" -f $username, $currentPassword))
$authHeaderValue = [Convert]::ToBase64String($bytes)

$response = Invoke-RestMethod "http://localhost:9200/_xpack/security/user/elastic/_password" -Method Post `
                                -Headers @{Authorization=("Basic {0}" -f $authHeaderValue)} `
                                -Body "{
    `"password`" : `"$newPassword`"
}"
1 Like

Thanks a lot forloop, it's working now.