Configuring SQL Server destinations
You can use SQL Server destinations to store historical results for analysis and integration with third-party systems. You can forward the results from saved questions and other data sources to a database table.
System requirements
-
Microsoft SQL Server 2008 or later, Microsoft SQL Server 2008 Express or later
-
Database application server must be accessible from the Tanium Module Server
-
User credentials with db_ddladmin and db_datawriter role membership to an account on the Microsoft SQL Server that can insert data, create tables (optional), and run stored procedures (optional)
Set up the database
Decide whether to use an existing database or create a new database.
Sample SQL Script for creating stored procedures
GO
/****** Object: Table [dbo].[connection_log] Script Date: 4/25/2017 8:02:32 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[connection_log](
[connectionRunId] [bigint] NOT NULL,
[connectionId] [bigint] NOT NULL,
[connectionName] [nvarchar](200) NOT NULL,
[source] [nvarchar](200) NOT NULL,
[databaseTable] [nvarchar](100) NULL,
[startTime] [datetime] NOT NULL,
[endTime] [datetime] NULL,
[runStatus] [nvarchar](20) NOT NULL,
[expectedRowCount] [bigint] NOT NULL,
[sourceRowCount] [bigint] NOT NULL,
[destinationRowCount] [bigint] NOT NULL,
PRIMARY KEY CLUSTERED
(
[connectionRunId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[sp_onConnectionFinish] Script Date: 4/25/2017 8:02:32 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_onConnectionFinish]
@connectionRunId bigint,
@runStatus nvarchar(20),
@sourceRowCount bigint,
@destinationRowCount bigint,
@finishTime datetime
as
BEGIN
update connection_log set runStatus = @runStatus, sourceRowCount = @sourceRowCount,
destinationRowCount = @destinationRowCount, endTime = @finishTime
where connectionRunId = @connectionRunId
END
GO
/****** Object: StoredProcedure [dbo].[sp_onConnectionStart] Script Date: 4/25/2017 8:02:32 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_onConnectionStart]
@connectionName nvarchar(200),
@connectionId bigint,
@connectionRunId bigint,
@source nvarchar(200),
@databaseTable nvarchar(100),
@startTime datetime,
@expectedRowCount bigint
AS
BEGIN
if exists (select * from connection_log where ConnectionRunId = @connectionRunId) BEGIN
delete connection_log where ConnectionRunId = @connectionRunId
END
insert into connection_log (connectionRunId, connectionId, connectionName, source, databaseTable,
startTime, endTime, runStatus, expectedRowCount, sourceRowCount, destinationRowCount)
values (@connectionRunId, @connectionId, @connectionName, @source, @databaseTable, @startTime, null,
'Running', isnull(@expectedRowCount, 0), 0, 0)
END
GO
You can use the following parameters for pre-run stored procedures:
-
Connection Name: @connectionName
-
Connection ID: @connectionId
-
Connection Run ID: @connectionRunId
-
Source Name: @source
-
Database Table: @databaseTable
-
Start Time: @startTime
-
Expected Row Count: @expectedRowCount
You can use the following parameters for post-run stored procedures:
-
Connection Name: @connectionName
-
Connection ID: @connectionId
-
Connection Run ID: @connectionRunId
-
Source Name: @source
-
Database Table: @databaseTable
-
Start Time: @startTime
-
Expected Row Count: @expectedRowCount
-
Run Status: @runStatus
-
Source Row Count: @sourceRowCount
-
Destination Row Count: @destinationRowCount
-
Finish Time: @endTime
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 SQL Server destination
Specify information about how to connect to your database application server, test the database application server connection, and configure which data is added to the database tables and rows.
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.
Map database table columns
(Optional) You can view and change the mapping of the data from your source to the columns in your database table.
If the source is a saved question, the following columns are also available for writing to the SQL Server destination:
-
Band Number: The source row number. When flattened, this number is in each row that is associated with a row number that is received from Tanium.
-
Row Number: The destination row number. This value is a counter for the rows that are output per connection run. The value is unique for each connection run.
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.
Save and verify connection
Your connection is listed on the Connect Overview page and data is sent to the Microsoft SQL Server at the interval you specified. You might want to check your database table to verify that the data is being exported correctly.