Download Installers from the Command-line

The documentation explains how to programmatically download LogScale collector installers using GraphQL queries and command-line tools. It provides detailed examples for querying available installers across multiple platforms (Windows, Linux, MacOS) using various programming languages and tools like curl, Python, Node.js, and Perl, along with instructions for downloading the installers using wget or curl once the appropriate URL is identified.

A list of available installers can be obtained from LogScale by running a GraphQL query against your LogScale instance:

Note

You must specify the url of your LogScale in $YOUR_LOGSCALE_URL

Raw
graphql
query {
  logCollectorInstallers 
  {name, url, type, version}
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $INGEST_TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $INGEST_TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $INGEST_TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query { ^
  logCollectorInstallers  ^
  {name, url, type, version} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $INGEST_TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}'
    "$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" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}';
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $INGEST_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" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}'''

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

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

const data = JSON.stringify(
    {"query" : "query {
  logCollectorInstallers 
  {name, url, type, version}
}"
}
);


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": {
    "logCollectorInstallers": [
      {
        "name": "humio-log-collector_1.7.4_linux_arm64.deb",
        "url": "http://localhost:8080/api/v1/log-collector/download/humio-log-collector_1.7.4_linux_arm64.deb",
        "type": "deb",
        "version": "1.7.4"
      },
      ...
  }
}

The query will return a JSON structure with a list of the available installers:

json
{
   "data" : {
      "logCollectorInstallers" : [
         {
            "architecture" : "amd64",
            "configExample" : "dataDirectory: C:\\ProgramData\\Log Collector\nsources:\n  windows_events:\n    type: wineventlog\n    channels:\n      - name: Application\n      - name: Security\n      - name: System\n    sink: humio\nsinks:\n  humio:\n    type: humio\n    token: <ingest-token>\n    proxy: none\n    url: $YOUR_LOGSCALE_URL\n",
            "name" : "logscale-collector_1.9.1_windows_amd64.msi",
            "type" : "msi",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_windows_amd64.msi",
            "version" : "1.9.1"
         },
         {
            "architecture" : "universal",
            "configExample" : null,
            "name" : "logscale-collector_1.9.1_macOS_universal.pkg",
            "type" : "pkg",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_macOS_universal.pkg",
            "version" : "1.9.1"
         },
         {
            "architecture" : "amd64",
            "configExample" : "dataDirectory: /var/lib/logscale-collector\nsources:\n  var_log:\n    type: file\n    include: /var/log/*\n    sink: humio\nsinks:\n  humio:\n    type: humio\n    token: <ingest-token>\n    url: $YOUR_LOGSCALE_URL\n",
            "name" : "logscale-collector_1.9.1_linux_amd64.deb",
            "type" : "deb",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_amd64.deb",
            "version" : "1.9.1"
         },
         {
            "architecture" : "amd64",
            "configExample" : "dataDirectory: /var/lib/logscale-collector\nsources:\n  var_log:\n    type: file\n    include: /var/log/*\n    sink: humio\nsinks:\n  humio:\n    type: humio\n    token: <ingest-token>\n    url: $YOUR_LOGSCALE_URL\n",
            "name" : "logscale-collector_1.9.1_linux_amd64.rpm",
            "type" : "rpm",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_amd64.rpm",
            "version" : "1.9.1"
         },
         {
            "architecture" : "arm64",
            "configExample" : "dataDirectory: /var/lib/logscale-collector\nsources:\n  var_log:\n    type: file\n    include: /var/log/*\n    sink: humio\nsinks:\n  humio:\n    type: humio\n    token: <ingest-token>\n    url: $YOUR_LOGSCALE_URL\n",
            "name" : "logscale-collector_1.9.1_linux_arm64.deb",
            "type" : "deb",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_arm64.deb",
            "version" : "1.9.1"
         },
         {
            "architecture" : "arm64",
            "configExample" : "dataDirectory: /var/lib/logscale-collector\nsources:\n  var_log:\n    type: file\n    include: /var/log/*\n    sink: humio\nsinks:\n  humio:\n    type: humio\n    token: <ingest-token>\n    url: $YOUR_LOGSCALE_URL\n",
            "name" : "logscale-collector_1.9.1_linux_arm64.rpm",
            "type" : "rpm",
            "url" : "$YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_arm64.rpm",
            "version" : "1.9.1"
         }
      ]
   }
}

The key elements from each entry are the type, which defines the installer type (for example msi for Windows, or deb for Debian package), and the url which contains the URL to use for the download.

Once the correct URL has been identified, use a tool such as wget to download the file:

shell
$ wget --method GET --header 'Authorization: Bearer $INGEST_TOKEN' $YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_arm64.rpm

Or curl

shell
$ curl -X GET -H "Authorization: Bearer $INGEST_TOKEN" \
    $YOUR_LOGSCALE_URL/api/v1/log-collector/download/logscale-collector_1.9.1_linux_arm64.rpm

Once you have the installer you can follow the corresponding installation instructions for each platform.