Closed bidandows closed 1 year ago
Hi. Based on that error alone, I would assume the index configuration you're sending (settings, mappings, etc.) is incorrect or incomplete. Perhaps you have a mapping where a field type is missing a 'length' parameter. It does not appear however, to be an issue with this package.
Hello @ThorbenJ and thank you for answering, Is it necessary to put the settings and mapping when creating a new index?
I am also having errors when testing if an index exists or not, this is the message error I am getting "ResponseError: "
.
Regarding create: The Elasticsearch JS client (https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#_create_2) is just calling the ES REST API: https://www.elastic.co/guide/en/elasticsearch/reference/8.8/indices-create-index.html - If what your trying works when you call that API directly, but not using this node, then there is a bug. However all I have to go on is that error message, and that suggests to me the error was from the API about something wrong with the parameters of the index you're trying to create.
The second issue in that screen shot, I assume is because you're using self signed certs for TLS, that are not trusted by the host that Node-Red is running on. In the elasticsearch connection configuration node, you have YAML/JOSN advance settings box where you can pass any options to the elasticsearch js client. Including TLS configuration to add trust for a private CA: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-connecting.html#auth-tls e.g.
tls:
ca: |
----- Start Certifiacte -----
dlskdls blah blah kdfldk
djfsjfkdlskfls fdlfksl;kfs
----- End Certificate -----
^ In YAML syntax, and just typed in not checked for syntax mistakes
Please note the input in the config node is not javascript, so calling functions like fs.readFileSync() wont work.
BR, Thorben
Hello @ThorbenJ ,
Yes, when calling the API directly it works fine here is the output of the curl request.
`curl --cacert ca.crt -u elastic:flex23 -X GET "https://localhost:9200/nacer/" | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 302 0 302 0 0 4032 0 --:--:-- --:--:-- --:--:-- 4081
{
"nacer": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "nacer",
"creation_date": "1686220540739",
"number_of_replicas": "1",
"uuid": "yWSP8UBqQKyXPilKrHb-Lg",
"version": {
"created": "8080099"
}
}
}
}
}`
Here are the ES logs when using the node to check the index.
`{"@timestamp":"2023-06-08T18:30:27.819Z", "log.level": "INFO", "message":"Authentication of [elastic] was terminated by realm [reserved] - failed to authenticate user [elastic]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[es01][system_critical_read][T#4]","log.logger":"org.elasticsearch.xpack.security.authc.RealmsAuthenticator","elastic search.cluster.uuid":"j2uXbHekTxaMVN332e8jSA","elasticsearch.node.id":"GTx8jgi5QCubhZWkpnJp0A","elasticsearch.node.name":"es01","elasticsearch.cluster.name":"docker-cluster"}`
When I put the auth in the advanced YAMl section I no longer "message":"Authentication of [elastic] was terminated by realm [reserved] - failed to authenticate user [elastic]",
in ES logs but the error on node-red "ResponseError: "
If you have Credential set to Basic then "auth" will be overwritten with the contents of identity and secret:
auth = {
username: this.credentials.ident,
password: this.credentials.secret
};
Unlike adv. config, identity and secret are kept in Node-red credential store.
If you want to set auth in adv. config, then set credential to "None" and it will not overwrite auth - but note anything in adv. config will be stored with the flow (inc. any flow exports) and not in Node-red credential store.
The problem in this ticket keeps changing?
I have set the credentials to "NONE" and now I am getting this error
"ReferenceError: node is not defined"
The problem in this ticket keeps changing?
- A problem with creating an index (i.e. PUT/POST API method; then
- TLS certificate verification; then
- Authentication with curl example of a GET API method (so not create)
The TLS certificate verification issue is no longer present but still has an authentication issue.
Hi.
So now we have found a bug in this package. The switch/case code to handle the different options for credentials, had a bug for the 'none' case (code path). I've just fixed that and pushed version 0.3.13 with that fixed.
However setting credentials to basic, and putting the username and password in identity and secret results in the same configuration as adding "auth":{"username":"xxx", "password":"xxx"} to Adv. conf, however with the added benefit that the credentials are stored more safely by node-red. Could it be that the username or password were entered wrong when you used 'basic'? Maybe there was an extra space in a copy/paste?
BR, Thorben
Good news, the nodes are working now for index PUT/GET, but I think you should change the create index node to handle the case when the index parameters are empty because the index is created successfully but still getting this error
"TypeError: Cannot read properties of undefined (reading 'length')"
Hello there,
While trying to create an index I get the error indicated in the title, what could be the issue?
BR