Configuring HTTP destinations
You can send data from Connect to a REST API. You can choose to send all the data to the REST API in a single batch or in multiple segments. Form data is not supported.
Configure a receiver
You must have a script on your server that can receive the HTTP request from Tanium.
Node.js example
'use strict';
const restify = require('restify');
const fs = require('fs');
const server = restify.createServer({ name: 'File Receiver' });
let file = 0;
const dir = 'files';
if (!fs.existsSync(dir)) {
fs.mkdirSync('files');
}
function postFile(req, res, next) {
const fileName = `files/testing${file++}.txt`;
const fileData = JSON.stringify(req.body);
fs.writeFile(fileName, fileData, err => {
if (err) {
console.error('err', err);
res.send(500, err);
} else {
console.log(`wrote to file ${fileName}`);
res.send(200);
}
next();
});
}
server.post('/post', postFile);
server.listen(17800, '0.0.0.0', () => {
console.log(`${server.name} listening at ${server.url}`);
});
Python example
from flask import Flask, request, Response
import os
import json
app = Flask(__name__)
file = 0
dir = 'files'
os.makedirs(dir, exist_ok=True)
@app.route("/post", methods=['POST'])
def connection_handle():
global file
file_data = json.dumps(request.get_json())
file_name = f"{dir}/testing{file}.txt"
file += 1
try:
file_handle = open(file_name, mode="w", encoding="utf-8")
file_handle.write(file_data)
file_handle.close()
except:
return Response('err', status=500, mimetype='application/json')
return 'done'
app.run(host = '0.0.0.0', port = 17800)
Ruby example
require "sinatra"
require "fileutils"
set :port, 17800
set :bind, "0.0.0.0"
file = 0
dir = "files"
FileUtils.mkdir_p dir
post "/post" do
file_data = JSON.parse request.body.read
file_name = "#{dir}/testing#{file}.txt"
file += 1
begin
File.write file_name, file_data.to_json
puts "wrote to file #{file_name}"
return
rescue Exception => e
status 500
"err #{e}"
end
end
Specify general connection information
Configure the connection source
The connection source determines what data you are sending to the destination. This data is usually information from Tanium, such as a saved question, question log, client status, or event. The settings vary depending on which source you choose.
For more information about available connection sources, see Connection sources.
If a Tanium solution or source shows Critical , the installed solution does not meet the minimum required version for proper compatibility and functionality. Upgrade the solution to the minimum required version or later.
Configure the HTTP destination
Specify the URL, method, and headers for the destination to which you want to send data.
Configure filters
(Optional) In the section, you can specify filters to modify the data that you are getting from your connection source before it is sent to the destination.
For more information about the types of filters you can configure, see Reference: Filtering options.
Format data for HTTP
You can choose to save your file in all of the available formats, as listed in Reference: Format types. The default format is JSON. Each format has slightly different configuration options, but all allow you to choose which column data to save.
In the section, you can change the Destination Label of each column and Value Type to force the column to be a String, Numeric, or Date/Time value.
If you choose Numeric for the value, you can specify a default value that is used if the data cannot be coerced into a numeric value. You can specify any negative or positive number.
If you choose Date/Time for the value, specify the format that you want to use for the column. For more information about how to use a variable, see Time stamp variables.
For more information about column customizations, see Reference: Column customizations.
Schedule the connection
Connections can run at a highly configurable time interval, such as multiple times per hour, day, week, or month.
Use the Schedule section to update the schedule:
-
Select Enable schedule.
-
In the Schedule Type, select Basic to build a schedule with the provided controls.
-
To view or edit the cron expression directly, select Advanced - Define as a Cron Expression, and use the Advanced field to edit the cron expression.
For more information about cron syntax, see Reference: Cron syntax for Connect.
Enable listening for an event
Connections with Event sources only run when a configured event is detected, and cannot be scheduled or manually run.
Use the Enablement section to send data when a configured event is detected:
-
Select Listen for this Event.