API Stability Long-Term

The updateSavedQuery() GraphQL mutation is used to update a saved query in LogScale.

For more information on saved queries, see the User Functions (Saved Searches) reference page where saved queries are discussed. Also, look at the Searching Data documentation page as it relates to recent queries and saving queries.

Syntax

Below is the syntax for the updateSavedQuery() mutation field:

graphql
updateSavedQuery(
     input: UpdateSavedQueryInput!
   ): UpdateSavedQueryPayload!

Below is an example of how this mutation field might be used:

Raw
graphql
mutation {
  updateSavedQuery( input:
     { id: "abc123",
       viewName: "humio",
       isLive: false
     } 
  )
  { savedQuery { id } }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  updateSavedQuery( input: ^
     { id: \"abc123\", ^
       viewName: \"humio\", ^
       isLive: false ^
     }  ^
  ) ^
  { savedQuery { id } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $INGEST_TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}';
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  updateSavedQuery( input:
     { id: \"abc123\",
       viewName: \"humio\",
       isLive: false
     } 
  )
  { savedQuery { id } }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  path: '/graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "updateSavedQuery": {
      "savedQuery": {
        "id": "abc123"
      }
    }
  }
}

Given Datatypes

UpdateSavedQueryInput has many parameters that may be given. Below is a list of them along with a description of each:

Table: UpdateSavedQueryInput

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 23, 2024
customLinkInteractions[CustomLinkInteractionInput]yes Long-TermThe custom links for interactions. See CustomLinkInteractionInput.
dashboardLinkInteractions[DashboardLinkInteractionInput]yes Long-TermThe dashboard links for interactions. See DashboardLinkInteractionInput.
endstring  Long-TermThe ending point of the saved query.
idstringyes Long-TermThe unique identifier of the saved query to update.
isLiveboolean  Long-TermWhether the saved query is executed continuously on live, streaming data.
namestring  Long-TermThe name of the saved query to update.
optionsstring  Long-TermAny options related to the saved query.
queryStringstring  Long-TermThe new query.
searchLinkInteractions[SearchLinkInteractionInput]yes Long-TermThe search links for interactions. See SearchLinkInteractionInput.
startstring  Long-TermThe starting point of the saved query.
updateParametersInteractions[UpdateParametersInteractionInput]yes Long-TermThe parameters to update for interactions. See UpdateParametersInteractionInput.
viewNamestringyes Long-TermThe name of the view associated with the saved query.
widgetTypestring  Long-TermThe type of widget for displaying the results of the saved query.

Returned Datatypes

The returned datatype UpdateSavedQueryPayload has one parameter and several sub-parameters. Click on the link below to see a table containing the sub-parameters:

Table: UpdateSavedQueryPayload

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Oct 4, 2024
savedQuerySavedQueryyes Long-TermThe saved query to update. See SavedQuery.