Reading time: 14 minutes
Content was updated: Oct 28, 2024
Falcon LogScale's HEC API is an alternative HTTP ingest endpoint. It is
capable of handling both structured and unstructured data, and is
primarily provided for compatibility with Splunk.
The endpoints for HEC can be found at /api/v1/ingest/hec
and
/services/collector
.
You will need to provide a Ingest Tokens in
the HTTP Authorization
header.
The ingest token contains the name of the repository the data is stored
in, and ingested events will be stored in the repository corresponding
to the ingest token.
If using an Organization API Token with the
Ingest across all repositories within organization
permission, then HEC allows ingest to any
repository specified as "index":
"repository-name"
in the body of a message, as long as the ingest
token is valid for any repository on the LogScale cluster. If
the named repository does not exist then an error will be returned.
This is a potential security issue on a public API endpoint, so this
option should only be used inside a trusted environment.
Below is an example of the sending a JSON document for ingest:
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/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"time" : 1537537729.0,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver",
"source" : "/var/log/application.log",
"sourcetype" : "applog",
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0,
"event" : {
"message" : "System shutdown",
"host" : { "ip" : "127.0.0.1", "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}
EOF
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"time" : 1537537729.0,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver",
"source" : "/var/log/application.log",
"sourcetype" : "applog",
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0,
"event" : {
"message" : "System shutdown",
"host" : { "ip" : "127.0.0.1", "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}
EOF
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec ^
-H "Authorization: Bearer $INGEST_TOKEN" ^
-H "Content-Type: text/plain; charset=utf-8" ^
-d @'{ ^
"time" : 1537537729.0, ^
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver", ^
"source" : "/var/log/application.log", ^
"sourcetype" : "applog", ^
"fields" : { "#env" : "prod" } ^
} ^
^
{ ^
"time" : 1537535729.0, ^
"event" : { ^
"message" : "System shutdown", ^
"host" : { "ip" : "127.0.0.1", "port" : 2222 } ^
}, ^
"fields" : { "#datacenter" : "amazon-east1" } ^
} '
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $INGEST_TOKEN "
-H "Content-Type: text/plain; charset=utf-8"
-d '{
"time" : 1537537729.0,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver",
"source" : "/var/log/application.log",
"sourcetype" : "applog",
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0,
"event" : {
"message" : "System shutdown",
"host" : { "ip" : "127.0.0.1", "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}'
"$YOUR_LOGSCALE_URL /api/v1/ingest/hec"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ;
my $json = '{
"time" : 1537537729.0,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver",
"source" : "/var/log/application.log",
"sourcetype" : "applog",
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0,
"event" : {
"message" : "System shutdown",
"host" : { "ip" : "127.0.0.1", "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}' ;
my $req = HTTP::Request->new("POST" , $uri );
$req->header("Authorization" => "Bearer $INGEST_TOKEN" );
$req->header("Content-Type" => "text/plain; charset=utf-8" );
$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/ingest/hec'
mydata = r'''{
"time" : 1537537729.0,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver",
"source" : "/var/log/application.log",
"sourcetype" : "applog",
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0,
"event" : {
"message" : "System shutdown",
"host" : { "ip" : "127.0.0.1", "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $INGEST_TOKEN" ,
"Content-Type" : "text/plain; charset=utf-8"
}
)
print (resp.text)
Node.js const https = require ('https' );
const data = JSON .stringify (
{
"time" : 1537537729.0 ,
"event" : "Fri, 21 Sep 2018 13:48:49 GMT - system started name=webserver" ,
"source" : "/var/log/application.log" ,
"sourcetype" : "applog" ,
"fields" : { "#env" : "prod" }
}
{
"time" : 1537535729.0 ,
"event" : {
"message" : "System shutdown" ,
"host" : { "ip" : "127.0.0.1" , "port" : 2222 }
},
"fields" : { "#datacenter" : "amazon-east1" }
}
);
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ,
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 ();
Data Handling for Large Data Events
The following examples detail the resulting ingested data for different
raw event volumes. For more information on limits, see
Limits & Standards .
Ingest Data within Limits 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/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}
EOF
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}
EOF
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec ^
-H "Authorization: Bearer $INGEST_TOKEN" ^
-H "Content-Type: text/plain; charset=utf-8" ^
-d @'{ ^
"fields": { ^
"#someTag": "a-small-value", ^
"someField1": "tiny-data-value", ^
"someField2": "small-data-value" ^
}, ^
"event": "also-a-tiny-data-value" ^
} '
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $INGEST_TOKEN "
-H "Content-Type: text/plain; charset=utf-8"
-d '{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}'
"$YOUR_LOGSCALE_URL /api/v1/ingest/hec"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ;
my $json = '{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}' ;
my $req = HTTP::Request->new("POST" , $uri );
$req->header("Authorization" => "Bearer $INGEST_TOKEN" );
$req->header("Content-Type" => "text/plain; charset=utf-8" );
$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/ingest/hec'
mydata = r'''{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $INGEST_TOKEN" ,
"Content-Type" : "text/plain; charset=utf-8"
}
)
print (resp.text)
Node.js const https = require ('https' );
const data = JSON .stringify (
{
"fields" : {
"#someTag" : "a-small-value" ,
"someField1" : "tiny-data-value" ,
"someField2" : "small-data-value"
},
"event" : "also-a-tiny-data-value"
}
);
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ,
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 Show:
Success (HTTP Response Code 200 OK)
Success (HTTP Response Code 200 OK)
All expected data and fields are present, and they are not truncated.
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/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "someValue1",
"someField2": "someValue2"
},
"event": "... More than 1MB of data ..."
}
EOF
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "someValue1",
"someField2": "someValue2"
},
"event": "... More than 1MB of data ..."
}
EOF
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec ^
-H "Authorization: Bearer $INGEST_TOKEN" ^
-H "Content-Type: text/plain; charset=utf-8" ^
-d @'{ ^
"fields": { ^
"#someTag": "a-small-value", ^
"someField1": "someValue1", ^
"someField2": "someValue2" ^
}, ^
"event": "... More than 1MB of data ..." ^
} '
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $INGEST_TOKEN "
-H "Content-Type: text/plain; charset=utf-8"
-d '{
"fields": {
"#someTag": "a-small-value",
"someField1": "someValue1",
"someField2": "someValue2"
},
"event": "... More than 1MB of data ..."
}'
"$YOUR_LOGSCALE_URL /api/v1/ingest/hec"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ;
my $json = '{
"fields": {
"#someTag": "a-small-value",
"someField1": "someValue1",
"someField2": "someValue2"
},
"event": "... More than 1MB of data ..."
}' ;
my $req = HTTP::Request->new("POST" , $uri );
$req->header("Authorization" => "Bearer $INGEST_TOKEN" );
$req->header("Content-Type" => "text/plain; charset=utf-8" );
$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/ingest/hec'
mydata = r'''{
"fields": {
"#someTag": "a-small-value",
"someField1": "someValue1",
"someField2": "someValue2"
},
"event": "... More than 1MB of data ..."
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $INGEST_TOKEN" ,
"Content-Type" : "text/plain; charset=utf-8"
}
)
print (resp.text)
Node.js const https = require ('https' );
const data = JSON .stringify (
{
"fields" : {
"#someTag" : "a-small-value" ,
"someField1" : "someValue1" ,
"someField2" : "someValue2"
},
"event" : "... More than 1MB of data ..."
}
);
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ,
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 Show:
Success (HTTP Response Code 200 OK)
Success (HTTP Response Code 200 OK)
The someField1 and
someField2 are not present, but
#someTag is.
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/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "... More than 1MB of data ..."
},
"event": "also-a-tiny-data-value"
}
EOF
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "... More than 1MB of data ..."
},
"event": "also-a-tiny-data-value"
}
EOF
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec ^
-H "Authorization: Bearer $INGEST_TOKEN" ^
-H "Content-Type: text/plain; charset=utf-8" ^
-d @'{ ^
"fields": { ^
"#someTag": "a-small-value", ^
"someField1": "tiny-data-value", ^
"someField2": "... More than 1MB of data ..." ^
}, ^
"event": "also-a-tiny-data-value" ^
} '
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $INGEST_TOKEN "
-H "Content-Type: text/plain; charset=utf-8"
-d '{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "... More than 1MB of data ..."
},
"event": "also-a-tiny-data-value"
}'
"$YOUR_LOGSCALE_URL /api/v1/ingest/hec"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ;
my $json = '{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "... More than 1MB of data ..."
},
"event": "also-a-tiny-data-value"
}' ;
my $req = HTTP::Request->new("POST" , $uri );
$req->header("Authorization" => "Bearer $INGEST_TOKEN" );
$req->header("Content-Type" => "text/plain; charset=utf-8" );
$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/ingest/hec'
mydata = r'''{
"fields": {
"#someTag": "a-small-value",
"someField1": "tiny-data-value",
"someField2": "... More than 1MB of data ..."
},
"event": "also-a-tiny-data-value"
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $INGEST_TOKEN" ,
"Content-Type" : "text/plain; charset=utf-8"
}
)
print (resp.text)
Node.js const https = require ('https' );
const data = JSON .stringify (
{
"fields" : {
"#someTag" : "a-small-value" ,
"someField1" : "tiny-data-value" ,
"someField2" : "... More than 1MB of data ..."
},
"event" : "also-a-tiny-data-value"
}
);
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ,
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 Show:
Success (HTTP Response Code 200 OK)
Success (HTTP Response Code 200 OK)
The someField1 and
someField2 are not present, but
#someTag is.
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/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "... More than 65535 bytes of data ...",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}
EOF
Mac OS or Linux (curl) One-line curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec \
-H "Authorization: Bearer $INGEST_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d @- << EOF
{
"fields": {
"#someTag": "... More than 65535 bytes of data ...",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}
EOF
Windows Cmd and curl curl -v -X POST $YOUR_LOGSCALE_URL/api/v1/ingest/hec ^
-H "Authorization: Bearer $INGEST_TOKEN" ^
-H "Content-Type: text/plain; charset=utf-8" ^
-d @'{ ^
"fields": { ^
"#someTag": "... More than 65535 bytes of data ...", ^
"someField1": "tiny-data-value", ^
"someField2": "small-data-value" ^
}, ^
"event": "also-a-tiny-data-value" ^
} '
Windows Powershell and curl curl.exe -X POST
-H "Authorization: Bearer $INGEST_TOKEN "
-H "Content-Type: text/plain; charset=utf-8"
-d '{
"fields": {
"#someTag": "... More than 65535 bytes of data ...",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}'
"$YOUR_LOGSCALE_URL /api/v1/ingest/hec"
Perl
use HTTP::Request;
use LWP;
my $INGEST_TOKEN = "TOKEN" ;
my $uri = '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ;
my $json = '{
"fields": {
"#someTag": "... More than 65535 bytes of data ...",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}' ;
my $req = HTTP::Request->new("POST" , $uri );
$req->header("Authorization" => "Bearer $INGEST_TOKEN" );
$req->header("Content-Type" => "text/plain; charset=utf-8" );
$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/ingest/hec'
mydata = r'''{
"fields": {
"#someTag": "... More than 65535 bytes of data ...",
"someField1": "tiny-data-value",
"someField2": "small-data-value"
},
"event": "also-a-tiny-data-value"
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $INGEST_TOKEN" ,
"Content-Type" : "text/plain; charset=utf-8"
}
)
print (resp.text)
Node.js const https = require ('https' );
const data = JSON .stringify (
{
"fields" : {
"#someTag" : "... More than 65535 bytes of data ..." ,
"someField1" : "tiny-data-value" ,
"someField2" : "small-data-value"
},
"event" : "also-a-tiny-data-value"
}
);
const options = {
hostname : '$YOUR_LOGSCALE_URL/api/v1/ingest/hec' ,
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 Show:
Failure (HTTP Response Code 500 Error; Can be retried)
Failure (HTTP Response Code 500 Error; Can be retried)
Entire request is dropped, no data in LogScale.