LogicMonitor DataMagic
LogicMonitor DataMagic's purpose is to present much of the information available in LogicMonitor as an offline relational database.
Currently Postgres and Microsoft SQL Server are supported.
Configuration
JSON file creation
LogicMonitor DataMagic configuration can get very complex. Currently, this is managed using a JSON document. We recommend that you create and manage this document offline using a JSON editor such as Visual Studio Code. The contents should then be pasted into the "Configuration" text area in the Connection.
Configuration template
Lines 1-4
- DatabaseType
- Required
- "SqlServer" OR "Postgres"
- DatabaseServerName
- Required
- The FQDN of the external database server
- DatabaseName
- Required
- The name of the database on the database server
- DatabaseUsername
- The username for connecting to the database
- When using SqlServerAuthenticationMethod of ActiveDirectoryServicePrincipal, this is the ClientId
- DatabasePassword
- The password for connecting to the database
- When using SqlServerAuthenticationMethod of ActiveDirectoryServicePrincipal, this is the ClientSecret
- DatabaseServerPort
- Optional
- Set only if your database is on a non-standard TCP port
- SqlServerAuthenticationMethod
- Optional
- Only set if using a DatabaseType of "SqlServer"
- Only set if using a SqlAuthenticationMethod other than "NotSpecified"
- Valid values:
- NotSpecified
- SqlPassword
- ActiveDirectoryPassword
- ActiveDirectoryIntegrated
- ActiveDirectoryInteractive
- ActiveDirectoryServicePrincipal
- ActiveDirectoryDeviceCodeFlow
- ActiveDirectoryManagedIdentity
- ActiveDirectoryMSI
- ActiveDirectoryDefault
- ActiveDirectoryWorkloadIdentity
Lines 5-7
Line 9
Lines 10 – 37
Line 12 – The DataSource Name
Line 13 – The AppliesTo field
Line 14 – Instance Inclusion expression
Lines 16-27
Line 17 – The DataPoint Name
Line 18 – The measurement unit
Line 19 - Calculation
- “Name”: “PercentUsed”
- “Calculation” : “100-PercentFree”
- “Name”: “PercentUsed”
- “Calculation”: “(BytesUsed/TotalBytes)*100”
Line 20 – Global Alert expression
Line 21 – Tags
Lines 22-24 – Properties
Lines 25 and 26 – InstanceDatapointProperties
- Condition 1 checks if the property system.categories is set, if it is it moves to condition 2, otherwise it enters a blank string as indicated by the empty quotes at before the final close parentheses
-
- Condition 2 switches on the value of system.categories and enters the value immediately after that class. If the value is A, the property stored is B, if its C, the value is D, and if its neither then the property value is blank, as denoted by the empty quotes after ‘D’
Optional Terms
"FakeExecutionTime" : "YYYY-MM-DD HH:mm:SS"
To be used within the “Database” section, for testing. Allows you to fake when the sync occurs so that it can be done e.g. in a previous month.
"ExcludeSdtPeriods" : false
To be used within the “Database” section. The default is false (e.g. when the term is omitted), but when explicitly set to true, the time series aggregations (stored in the TimeSeriesDataAggregations table) will ignore data points that were deemed to be within a period of Service Down Time (SDT). Historical SDT periods are queried via the LogicMonitor API for the Device Data Source Instance, the Device Data Source, the Device, and the Device Groups all the way to the root. SDT periods are then flattened and only data that does not fall inside an SDT period is included. 'Current' SDT periods are not queries, i.e. if there is an ongoing period of SDT, because we are only concerned with historical data.
When the property is missing it is equivalent to false.
"LimitAlertSyncToDataSourceAppliesTo" : true
To be used prior (or after) the "Database" section (e.g. underneath the "DimensionSyncHaltOnError" property on line 9), this setting, when present, allows you only sync Alerts for the devices relevant to the "AppliesTo" property, when set and not empty, of each DataSource (e.g. the "AppliesTo" on line 13).
When the property is missing it is equivalent to false, and so Alerts for all Devices will be synced.
"MinutesOffset" : xxx
"StartDateTimeUtc" : "YYYY-MM-DD HH:mm:SS"
AggregationReset
To be used within the database section, this allows you to reset the time series data aggregations (i.e. truncate the table / reset them), only if time series data is set to be processed. This is controlled via the Admin app via the DataMagic > Syncs menu, by ticking the "Sync Time Series Data" checkbox on a Sync.
Connection configuration
Once you have created the configuration file, you will need to create a new LogicMonitor connection with a user that has read access, and copy the JSON into the “Configuration” Field.
Sync configuration
You will then need to go to the DataMagic Syncs page.
Ensure the Connection field is set to the connection you just set up. It is recommended to select the options shown above, i.e. Sync to Database, Sync Dimensions, and Sync Time Series Data.
- Sync to file would create a downloadable file of the data
- Sync Dimensions is needed to get the Devices, DataSources, DataPoints, and Instances
- Sync Logs works as expected
- Sync Events gathers the alerts, however, this adds a lot of time to the sync
- Sync Time Series Data gathers the aggregations for each of the instances.
- Sync to trigger will allow you to select another sync to automatically happen after this one finishes
- Schedule to trigger allows you to select a schedule to automatically run after the sync finishes
The first time you run the sync, the database will be created, unless the “DatabaseConnectionId” line is used and set to an existing database ID. Once the Database has been created, a connection to it will have to be set up before the data can be used in any macros.
Accessing the data
Data access is via a SQL connection. Please see support for credentials and access.
Database Schema
Whether you have configured for SQL Server or Postgres, you will need to understand the Database Schema.
Most table relations are self-explanatory (Websites has a foreign key into WebsiteGroups on Website.WebsiteGroupId to WebsiteGroup.Id). However, the instance relationships are as follows: