Hi All,
I am trying to create a rest API with the NodeJS client so that I can retrieve data from Elastic cloud. Now when I create the client in node and return the client everything is empty.
So client.cat
for example is empty. Which I would like to use to see all my available indexes. Is there something that I am missing? Because there is data in this environment which is used in an Kibana dashboard for example.
Is there anyone who can explain how I can make the data available?
-- code to create client --
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
node: 'My-URL..westeurope.azure.elastic-cloud.com:9243/',
auth: {
apiKey: {
id: 'API-ID',
api_key: 'API-Key'
}
}
})
res.json(client)
-- JSON return in web browser--
{
"name": "elasticsearch-js",
"serializer": {
},
"connectionPool": {
"connections": [
{
"url": "My-URL..westeurope.azure.elastic-cloud.com",
"id": "My-URL..westeurope.azure.elastic-cloud.com",
"headers": {
},
"deadCount": 0,
"resurrectTimeout": 0,
"_openRequests": 0,
"status": "alive",
"roles": {
"master": true,
"data": true,
"ingest": true,
"ml": false
}
}
],
"size": 1,
"auth": {
"apiKey": {
"id": "API-ID",
"api_key": "API-Key"
}
},
"_ssl": null,
"_agent": null,
"dead": [
],
"resurrectTimeout": 60000,
"resurrectTimeoutCutoff": 5,
"pingTimeout": 3000,
"_sniffEnabled": false,
"resurrectStrategy": 1
},
"transport": {
"connectionPool": {
"connections": [
{
"url": "My-URL..westeurope.azure.elastic-cloud.com",
"id": "My-URL..westeurope.azure.elastic-cloud.com",
"headers": {
},
"deadCount": 0,
"resurrectTimeout": 0,
"_openRequests": 0,
"status": "alive",
"roles": {
"master": true,
"data": true,
"ingest": true,
"ml": false
}
}
],
"size": 1,
"auth": {
"apiKey": {
"id": "API-ID",
"api_key": "API-Key"
}
},
"_ssl": null,
"_agent": null,
"dead": [
],
"resurrectTimeout": 60000,
"resurrectTimeoutCutoff": 5,
"pingTimeout": 3000,
"_sniffEnabled": false,
"resurrectStrategy": 1
},
"serializer": {
},
"maxRetries": 3,
"requestTimeout": 30000,
"suggestCompression": false,
"compression": false,
"context": null,
"headers": {
"user-agent": "elasticsearch-js/7.9.0 (win32 10.0.19041-x64; Node.js v10.16.3)"
},
"sniffInterval": false,
"sniffOnConnectionFault": false,
"sniffEndpoint": "_nodes/_all/http",
"name": "elasticsearch-js",
"opaqueIdPrefix": null,
"_sniffEnabled": false,
"_nextSniff": 0,
"_isSniffing": false
},
"helpers": {
"maxRetries": 3
},
"async_search": {
},
"asyncSearch": {
},
"autoscaling": {
},
"cat": {
},
"ccr": {
},
"cluster": {
},
"dangling_indices": {
},
"danglingIndices": {
},
"enrich": {
},
"eql": {
},
"graph": {
},
"ilm": {
},
"indices": {
},
"ingest": {
},
"license": {
},
"migration": {
},
"ml": {
},
"monitoring": {
},
"nodes": {
},
"rollup": {
},
"searchable_snapshots": {
},
"searchableSnapshots": {
},
"security": {
},
"slm": {
},
"snapshot": {
},
"sql": {
},
"ssl": {
},
"tasks": {
},
"transform": {
},
"watcher": {
},
"xpack": {
}
}