Use the lookup endpoints to download, upload, 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
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.
GET /api/v1/repositories/repository/location/files/filename
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) 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"
Mac OS or Linux (curl) One-line 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"
Windows Cmd and curl 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"
Windows Powershell and curl 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"
Perl
use HTTP::Request;
use LWP;
my $INGEST_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" ;
Python
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)
Node.js 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);
}
LogScale enables you to download shared files that have been
uploaded to it. For the GET
form, this endpoint returns the
document.
GET /api/v1/uploadedfiles/shared/filename
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"
Mac OS or Linux (curl) One-line curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"
Windows Cmd and curl curl -v -X GET $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json ^
-H "Authorization: Bearer $TOKEN" ^
-H "Content-Type: application/json"
Windows Powershell and curl curl.exe -X GET
-H "Authorization: Bearer $TOKEN "
-H "Content-Type: application/json"
"$YOUR_LOGSCALE_URL /api/v1/uploadedfiles/shared/$YOUR_FILE_NAME .json"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$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" ;
Python
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json'
resp = requests.get(url,
headers = {
"Authorization" : "Bearer $TOKEN" ,
"Content-Type" : "application/json"
}
)
print (resp.text)
Node.js const https = require ('https' );
let request = https.get ('$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$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);
}
LogScale enables you to upload files. The files must be JSON or
CSV files.
POST api/v1/repositories/$REPOSITORY_NAME/files
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.json
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.json
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files ^
-H "Authorization: Bearer $TOKEN" ^
-F "file=@$YOUR_FILE_NAME.json
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $TOKEN "
-F "file=@$YOUR_FILE_NAME .json
" $YOUR_LOGSCALE_URL /api/v1/repositories/$REPOSITORY_NAME /files"
Perl
use HTTP::Request;
use LWP;
my $INGEST_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" ;
Python
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)
Node.js const https = require ('https' );
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files' ,
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 ();
If you are a self-hosted user, LogScale enables you to upload
shared files. The files must be JSON or CSV files.
POST /api/v1/uploadedfiles/shared
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.json
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared \
-H "Authorization: Bearer $TOKEN" \
-F "file=@$YOUR_FILE_NAME.json
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared ^
-H "Authorization: Bearer $TOKEN" ^
-F "file=@$YOUR_FILE_NAME.json
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $TOKEN "
-F "file=@$YOUR_FILE_NAME .json
" $YOUR_LOGSCALE_URL /api/v1/uploadedfiles/shared"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my %form = (
"file" => "@$YOUR_FILE_NAME.json" ,
);
my $uri = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared' ;
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" ;
Python
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared'
mydata = r''
files = {
'file' : (None ,'@$YOUR_FILE_NAME.json' ),
}
resp = requests.post(url,
files = files,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print (resp.text)
Node.js const https = require ('https' );
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared' ,
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 ();
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:
DELETE /api/v1/repositories/REPOSITORY_NAME/files/filename
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"
Mac OS or Linux (curl) One-line curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"
Windows Cmd and curl curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME.json ^
-H "Authorization: Bearer $TOKEN"
Windows Powershell and curl curl.exe -X DELETE
-H "Authorization: Bearer $TOKEN "
"$YOUR_LOGSCALE_URL /api/v1/repositories/REPOSITORY_NAME/files/$YOUR_FILE_NAME .json"
Perl
use HTTP::Request;
use LWP;
my $INGEST_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" ;
Python
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)
Node.js 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);
}
LogScale enables you to delete shared files that have been
uploaded to it. For self-hosted users, a file can be deleted from all
repositories using the following:
DELETE /api/v1/uploadedfiles/shared/filename
Show:
Mac OS or Linux (curl) Mac OS or Linux (curl) One-line Windows Cmd and curl Windows Powershell and curl Perl Python Node.js
Mac OS or Linux (curl) curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"
Mac OS or Linux (curl) One-line curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json \
-H "Authorization: Bearer $TOKEN"
Windows Cmd and curl curl -v -X DELETE $YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json ^
-H "Authorization: Bearer $TOKEN"
Windows Powershell and curl curl.exe -X DELETE
-H "Authorization: Bearer $TOKEN "
"$YOUR_LOGSCALE_URL /api/v1/uploadedfiles/shared/$YOUR_FILE_NAME .json"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$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" ;
Python
import requests
url = '$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$YOUR_FILE_NAME.json'
resp = requests.delete(url,
headers = {
"Authorization" : "Bearer $TOKEN"
}
)
print (resp.text)
Node.js const https = require ('https' );
let request = https.delete ('$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/$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,mgr
Example: 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" }
]