Return Elasticsearch slowlogs settings to default - elasticsearch

I want to be able to set the slowlogs time to 0 for a period, then reset the setting back to the default.
I use
curl -X PUT -H "Content-Type: application/json" -d '{"index.search.slowlog.threshold.query.warn": "0s"}' "<ADDRESS>:9200/index/_settings"
to activate slowlogs. which adds
"search": {
"slowlog": {
"threshold": {
"query": {
"warn": "0s"
}
}
}
}
to the settings. I can do
curl -X PUT -H "Content-Type: application/json" -d '{"index.search.slowlog.threshold.query.warn": "-1"}' "<ADDRESS>:9200/index/_settings"
to deactivate slowlogs, but that leaves the new settings block in place where I want the settings to return to what they were before my meddling.
Is there a way to return the settings to default? (Ideally removing the whole new block so the settings are exactly as they were before.)

You can reset to default by passing null as the value of a setting.
curl -X PUT -H "Content-Type: application/json" \
-d '{"index.search.slowlog.threshold.query.warn": null}' \
"<ADDRESS>:9200/index/_settings"
Elasticsearch documentation for updating index settings via API
https://www.elastic.co/guide/en/elasticsearch/reference/7.12/indices-update-settings.html#reset-index-setting

What you want is not possible, Instead of that you can have a look at https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-slowlog.html and see what are the default values of slow log settings and then when you want to revert these, just update the log setting with the default values.

Related

Opendistro elasticsearch, no permissions for [ ] and User [name=admin, roles=[admin]

I try to run this command on elasticsearch server but i get error for permission.
I use opendistro for elasticsearch
curl -XPUT 'localhost:9200/_settings' -H 'Content-Type: application/json' -H 'securitytenant: Private' -u admin --insecure -d '{
"index" : {
"number_of_replicas" : 0
}
}'
{“error”:{“root_cause”:[{“type”:“security_exception”,“reason”:“no
permissions for [ ] and User [name=admin, roles=[admin],
requestedTenant=Private]”}],“type”:“security_exception”,“reason”:“no
permissions for [ ] and User [name=admin, roles=[admin],
requestedTenant=Private]”},“status”:403}
I tried also with out securitytenant but with the same error permission.
Other command's they run with success.
I have the same problem after migrating to opendistro with elasticsearch 7.
I did test creating new roles and cluster/index permissions, but didn't works.
Finally, what I did is curl a more specific url, specifying the index pattern, something like ...
curl -XPUT 'http://localhost:9200/logstash-*/_settings?pretty' -H 'Content-Type: application/json' -d '{"number_of_replicas": 0}' --insecure -u admin:...
And it works XD.
Acknowledge true.
Try with that.
Good look.

Okta application just redirect to a url

One of our requirements Is provision an app to an Okta user so he can click the app box and just redirect to an url with some query string parameters, no login required, is this possible using Okta?
You can add a Bookmark Application using the Apps API:
curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{
"name": "bookmark",
"label": "Custom Bookmark App",
"signOnMode": "BOOKMARK",
"settings": {
"app": {
"requestIntegration": false,
"url": "https://example.com/bookmark.htm?your=query&params=stuff"
}
}
}' "https://${org}.okta.com/api/v1/apps"
Then assign that app to a user:
curl -v -X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{}' "https://${org}.okta.com/api/v1/apps/:appId/users/:userId"
To add on to kevlened's accepted answer, you can add a bookmark app through the Admin UI by going to Applications >> Applications >> Add Application >> search for "bookmark" from the application templates and you'll get the option to add a Bookmark App. This works in Version 2018.07 and perhaps earlier.

How to update couchbase lite view with Rest API?

How to update couchbase lite view with Rest API ?
From Rest API how to tell indexer that view is updated . I have tried the below code but it did not work.It still returns the old index.
What is the correct way of telling indexer that view is updated so that it can recreate the index.
'PUT'
{db}/_design/todo
{
"_rev":"hf675757577hhfh",
"views":{
"list":{
"map":function(doc){
if(doc.type=='list')
{
emit(doc._id,{"name":doc.name});
}
},
//"version":"1.0" (I have tryied this but not work)
}
}
}
//My view create request was like below:
{db}/_design/todo
{
"views":{
"list":{
"map":function(doc){
if(doc.type=='list')
{
emit(doc._id,{"name":doc.name});
}
},
//"version":"1.0" (I have tryied this but not work)
}
}
}
It looks like you may just have some formatting problems. This shows how to do what you're trying from the command line:
curl -X PUT 'http://localhost:4985/db/_design/todo' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ "_rev": "hf675757577hhfh", "views": { "list": { "map": "function(doc) { if (doc.type == \"list\") { emit(doc._id, { \"name\": doc.name }); }}"}}}'
You can test your results with this command:
curl -X GET 'http://localhost:4985/db/_design/todo/_view/list'
You may want to refer to the documentation, which has more examples, at https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/views/index.html

How do I map the JSON body of a GET request to a parameter?

I have the following definition in my endpoint:
params do
requires :entities do
requires :id, type: String
optional :email, type: String
optional :phone, type: String
end
end
post "test" do
end
Note this only works as a POST request and the following CURL will work:
curl -XPOST localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'
However, the moment I change the declaration to get "test" instead of post, the corresponding curl request with -XGET no longer works due to the following validation error:
{"error":"entities is missing"}
If I remove the params requirements I can manually inspect the params hash at runtime and see that it only has a single key "route_info"
I'm currently using Grape 0.7.0
It happens because by specifying -d option you pass parameters in the body of the request while your endpoint is expecting them in the path as part of the url. Check here why it's a bad idea to pass body parameters in a GET request.
However, can use that option but if combination with -G.
-G, --get
When used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request
instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
So that your get request by using -d would look like:
curl -XGET -G localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'

Input::all() is not working - laravel 4

I'm new to Laravel, tried posting data using the following cURL command but when I try to read data, it wouldn't do it.
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":100}' api.xyz.com/test
There's a solution here* using file_get_contents but I'm sure there must be a better way:
Laravel - POST data is null when using external request
I ran the following curl command
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"John", "surname":"Doe"}' http://localhost/laravel/public/test
and returned a json_encode(Input::all()) in my HomeController#test and got the following output
{"name":"John","surname":"Doe"}
HomeController.php
public function test()
{
return json_encode(Input::all());
}
routes.php
Route::post('/test', 'HomeController#test');

Resources