Lookup API
Use the lookup endpoints to create, download, upload, update, and delete
files that can be used by the match()
function.
You can upload files in CSV or JSON format. Upload files as multipart form
data. The file should be in a part named
file.
Files can be uploaded to a repository or files can be uploaded as shared
files that are available in all repositories. Uploading a file with the same
name will replace the original file that was uploaded previously. Shared
files are visible in all repositories and can be used by all users. Only
root users can upload, delete and edit shared files. Shared files are
referenced from functions like match(),
by filename preprended with /shared/.
For example /shared/myfile.csv
Create files from query
LogScale enables you to create new lookup files based on the result of a recently run query. The files must be CSV.
| Description | Create a file based on a recently run query. | ||
| Method | POST /api/v1/repositories/ | ||
| Request Data | |||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
repository | The repository name | string | required |
| Query Arguments | Description | Data type | Required? |
filename | Name of the file to create. Must be .csv. | string | required |
queryId | The ID of the recently run query whose results should be saved as a lookup file | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
POST /api/v1/repositories/repository/filefromquery?queryId=id&fileName=filecurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv \
-H "Authorization: Bearer $TOKEN"curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv \
-H "Authorization: Bearer $TOKEN"curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv ^
-H "Authorization: Bearer $TOKEN"curl.exe -X POST
-H "Authorization: Bearer $TOKEN"
"$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv';
my $json = '';
my $req = HTTP::Request->new("POST", $uri );
$req->header("Authorization" => "Bearer $TOKEN");
$req->content( $json );
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv'
mydata = r''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
const options = {
hostname: '$YOUR_LOGSCALE_URL',
path: 'api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=$YOUR_FILE_NAME.csv',
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();Download Files
LogScale enables you to download files that have been uploaded to
it. For the GET form, this endpoint
returns the document.
There is also a GraphQL query for this.
| Description | Download a file from a repository in the cluster. | ||
| Method | GET /api/v1/repositories/ | ||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
filename | Name of the file to download; must be .csv or .json. | string | required |
repository | The repository name | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
GET /api/v1/repositories/repository/location/files/filenamecurl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json ^
-H "Authorization: Bearer $TOKEN" ^
-H "Content-Type: application/json"curl.exe -X GET
-H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json"
"$YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json';
my $req = HTTP::Request->new("GET", $uri );
$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json'
resp = requests.get(url,
headers = {
"Authorization" : "Bearer $TOKEN",
"Content-Type" : "application/json"
}
)
print(resp.text)const https = require('https');
let request = https.get('$YOUR_LOGSCALE_URL/api/v1/repositories/repository/location/files/$YOUR_FILE_NAME.json', (res) => {
if (res.statusCode !== 200) {
console.error(`Error from server. Code: ${res.statusCode}`);
res.resume();
return;
}
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('close', () => {
console.log('Response:');
console.log(JSON.parse(data));
});
});
return(undef,undef);
}Upload Files
LogScale enables you to upload files. The files must be JSON or CSV files.
| Description | Upload a file to a repository. | ||
| Method | POST /api/v1/repositories/ | ||
| Request Data | |||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
repository | The repository name | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
POST api/v1/repositories/$REPOSITORY_NAME/filescurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files ^
-H "Authorization: Bearer $TOKEN" ^
-F "file=@$YOUR_FILE_NAME.jsoncurl.exe -X POST
-H "Authorization: Bearer $TOKEN"
-F "file=@$YOUR_FILE_NAME.json
"$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my %form = (
"file" => "@$YOUR_FILE_NAME.json",
);
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files';
my $json = '';
my $req = HTTP::Request->new("POST", $uri, \%form );
$req->header("Authorization" => "Bearer $TOKEN");
$req->content( $json );
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files'
mydata = r''
files = {
'file': (None,'@$YOUR_FILE_NAME.json'),
}
resp = requests.post(url,
files = files,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
const options = {
hostname: '$YOUR_LOGSCALE_URL',
path: 'api/v1/repositories/$REPOSITORY_NAME/files',
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();Update Files
LogScale enables you to update existing files with new rows, either by appending or updating existing rows. The files must be CSV. For more information about the update options, see Update existing lookup files from the Search page.
| Description | Update a file in a repository. | ||
| Method | PATCH /api/v1/repositories/ | ||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
filename | Name of the file to update. Must be .csv. | string | required |
repository | The repository name | string | required |
| Query Arguments | Description | Data type | Required? |
ignoreCase | Whether or not to ignore matching case when the updateMode is update. Only allowed, and necessary, for that mode. | string | optional |
keyColumns | The key columns to use when updateMode is update. Only allowed, and necessary, for that mode. | string | optional |
updateMode | How to update the file. Can be either overwrite, append, or update. | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
PATCH /api/v1/repositories/REPOSITORY_NAME/files/filename?updateMode=mode&keyColumns=columns&ignoreCase=ignoreCasecurl -v -X PATCH $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X PATCH $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode ^
-H "Authorization: Bearer $TOKEN" ^
-F "file=@$YOUR_FILE_NAME.jsoncurl.exe -X PATCH
-H "Authorization: Bearer $TOKEN"
-F "file=@$YOUR_FILE_NAME.json
"$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my %form = (
"file" => "@$YOUR_FILE_NAME.json",
);
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode';
my $json = '';
my $req = HTTP::Request->new("PATCH", $uri, \%form );
$req->header("Authorization" => "Bearer $TOKEN");
$req->content( $json );
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode'
mydata = r''
files = {
'file': (None,'@$YOUR_FILE_NAME.json'),
}
resp = requests.patch(url,
files = files,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
const options = {
hostname: '$YOUR_LOGSCALE_URL',
path: 'api/v1/repositories/$REPOSITORY_NAME/files/filename?updateMode=mode',
port: 443,
method: 'PATCH',
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();Update files from query
LogScale enables you to update existing lookup files based on the result of a recently run query. The files must be CSV. For more information about the update options, see Update existing lookup files from the Search page.
| Description | Update an existing file based on a recently run query. | ||
| Method | PATCH /api/v1/repositories/ | ||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
repository | The repository name | string | required |
| Query Arguments | Description | Data type | Required? |
filename | Name of the file to update. Must be .csv. | string | required |
ignoreCase | Whether or not to ignore matching case when the updateMode is update. Only allowed, and necessary, for that mode. | string | optional |
keyColumns | The key columns to use when updateMode is update. Only allowed, and necessary, for that mode. | string | optional |
queryId | The ID of the query whose results should be updated in a lookup file | string | required |
updateMode | How to update the file. Can be either overwrite, append, or update. | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
PATCH /api/v1/repositories/repository/filefromquery?queryId=id&fileName=file&updateMode=mode&keyColumns=columns&ignoreCase=ignoreCasecurl -v -X PATCH $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.jsoncurl -v -X PATCH $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode ^
-H "Authorization: Bearer $TOKEN" ^
-F "file=@$YOUR_FILE_NAME.jsoncurl.exe -X PATCH
-H "Authorization: Bearer $TOKEN"
-F "file=@$YOUR_FILE_NAME.json
"$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my %form = (
"file" => "@$YOUR_FILE_NAME.json",
);
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode';
my $json = '';
my $req = HTTP::Request->new("PATCH", $uri, \%form );
$req->header("Authorization" => "Bearer $TOKEN");
$req->content( $json );
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode'
mydata = r''
files = {
'file': (None,'@$YOUR_FILE_NAME.json'),
}
resp = requests.patch(url,
files = files,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
const options = {
hostname: '$YOUR_LOGSCALE_URL',
path: 'api/v1/repositories/$REPOSITORY_NAME/filefromquery?queryId=id&fileName=file&updateMode=mode',
port: 443,
method: 'PATCH',
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();Status of running operation
To check on the status of a running operation from one of the endpoints "Update files", "Create a file from query", or "Update a file from query" call this endpoint with the ID returned from the other endpoint.
| Description | Get the status of an operation started through another endpoint. | ||
| Method | GET /api/v1/repositories/ | ||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
operationId | ID of the operation. | string | required |
repository | The repository name | string | required |
| Return Codes | |||
| 200 | Operation finished. | ||
| 202 | The operation is in progress; check again after a short delay | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
GET /api/v1/repositories/repository/fileoperation/operationIDcurl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID \
-H "Authorization: Bearer $TOKEN"curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID \
-H "Authorization: Bearer $TOKEN"curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID ^
-H "Authorization: Bearer $TOKEN"curl.exe -X GET
-H "Authorization: Bearer $TOKEN"
"$YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID';
my $req = HTTP::Request->new("GET", $uri );
$req->header("Authorization" => "Bearer $TOKEN");
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID'
resp = requests.get(url,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
let request = https.get('$YOUR_LOGSCALE_URL/api/v1/repositories/repository/fileoperation/operationID', (res) => {
if (res.statusCode !== 200) {
console.error(`Error from server. Code: ${res.statusCode}`);
res.resume();
return;
}
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('close', () => {
console.log('Response:');
console.log(JSON.parse(data));
});
});
return(undef,undef);
}Delete Files
LogScale enables you to delete files that have been uploaded to it. For Cloud users, a file can be deleted from all repositories using the following:
| Description | Delete a file from a repository. | ||
| Method | DELETE /api/v1/repositories/ | ||
| Authentication Required | yes | ||
| Path Arguments | Description | Data type | Required? |
filename | Name of the file to download; must be .csv or .json. | string | required |
repository | The repository name | string | required |
| Return Codes | |||
| 200 | Operation started. Response will contain ID to use with the "Status of running operation" endpoint. | ||
| 400 | Bad request | ||
| 500 | Request failed | ||
DELETE /api/v1/repositories/REPOSITORY_NAME/files/filenamecurl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json ^
-H "Authorization: Bearer $TOKEN"curl.exe -X DELETE
-H "Authorization: Bearer $TOKEN"
"$YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my $uri = '$YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json';
my $req = HTTP::Request->new("DELETE", $uri );
$req->header("Authorization" => "Bearer $TOKEN");
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json'
resp = requests.delete(url,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print(resp.text)const https = require('https');
let request = https.delete('$YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json', (res) => {
if (res.statusCode !== 200) {
console.error(`Error from server. Code: ${res.statusCode}`);
res.resume();
return;
}
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('close', () => {
console.log('Response:');
console.log(JSON.parse(data));
});
});
return(undef,undef);
}Example Contents for a CSV File
Whitespace gets included in the keys and values. To include the separator
"," in a value,
quote using the "
character.
userid,name
1,chr
2,krab
"4","p,m"
7,mgrExample: contents for a file in JSON format using an object as root of the file.
In this variant, the key field does not have a name.
{
"1": { "name": "chr" },
"2": { "name": "krab" },
"4": { "name": "pmm" },
"7": { "name": "mgr" }
}Example: contents for a file in JSON format using an array as root of the file.
In this variant, you select which field is the key using the
field parameter in
match().
[
{ "userid": "1", "name": "chr" },
{ "userid": "2", "name": "krab" },
{ "userid": "4", "name": "pmm" },
{ "userid": "7", "name": "mgr" }
]