Skip to content

Assure1 Metric File Collector

Overview

The Assure1 Metric File Collector tails a local file and processes any lines written to the file through rules, the results of which can be saved as metrics which can then be compared for thresholding. This collector is device and instance oriented.

Note

Only lines that are written to the file while the collector is running will be processed.

File Collector Setup

  1. Update the application configuration to read the correct data file.

  2. Enable the default Service, unless a specific configuration option is needed.

    Configuration -> Broker Control -> Services

Default Service

Field Value
Package Name coreCollection-app
Service Name Metric File Collector
Service Program bin/core/collection/FileCollectord
Service Arguments
Service Description Metric rules-based file collector
Failover Type Standalone (Supported: Standalone, Primary/Backup)
Status Disabled
Privileged (Checked)

Default Configuration

Name Value Possible Values Notes
BaseRules collection/metric/file/base.rules Text, 255 characters Relative path to Base Rules.
BranchDir core/default Text, 255 characters Relative path to Rules dir.
CheckTime 900 Integer How often (in seconds) where the application checks to see if there are any relevant changes.
File var/metrics.log Text, 255 characters The file to be tailed. - NO RELOAD CONFIG SUPPORT.
IncludeRules collection/metric/file/base.includes Text, 255 characters Relative path to Include Rules.
LoadRules collection/metric/file/base.load Text, 255 characters Relative path to Load Rules.
LogFile logs/MetricFileCollector.log Text, 255 characters Relative path to Log File.
LogLevel ERROR OFF, FATAL, ERROR, WARN, INFO, DEBUG Logging level used by application.
Threads 3 Integer Number of process threads created. The collector takes a third of this value (rounded up) for database threads unless overridden by the "DBThreads" application configuration.
DBThreads Integer Optional - Number of database threads to be created. If not specified, defaults to a third (rounded up) of "Threads" application configuration.
SendAllViolations Disabled Enabled/Disabled Optional - If enabled, thresholds will send violation notifications every poll cycle rather than only on state change. Requires 'ThresholdThreads'.
ThresholdThreads Integer Optional - Number of threshold threads to be created. Enables the checking of thresholds in the application instead of the Default Threshold Engine. If not specified, application threshold checking is disabled.

Rules

This collector uses the Assure1 standard rules architecture. The rules are written in Perl syntax. Refer to the following guides for details on rules creation:

Tokens

The collector exposes the following tokens for rules processing.

Token Description
$Message->{line} The data received from the collector.
$AppConfig Hash reference to the application configuration name-value pairs that were configured. (i.e. use $AppConfig->{'Host'} to retrieve the set value for 'Host'.)
$CustomHash Custom key, value cache available across all rules. Contents commonly defined in Load Rules then used in Base or other rules. NOTE: This variable is a shared object and any additional sub hashes or arrays must be shared before use or it will cause the error: "Invalid value for shared scalar". Instantiate the sub hash/array using '&share({})' e.g.
$CustomHash->{SubObject} = &share({});
$StorageHash Internal cache used as the StorageHash option when calling rules functions such as FindDeviceID(). NOTE: The structure of this cache is subject to change! Not recommended for custom global storage or manual manipulation; use $CustomHash.

Example Integration

In this example, a comma separated list of response time metric data is being written to a file in the following format:

Time,DNS,IP,Instance,Value,Status

Here is the code that could be used to process the data:

# Split the line from the tailed file at each comma and save the values in @Fields
@Fields = split(/,/, $Message->{line});

# Variables used in creating Instance and Metric
my $DeviceID     = 0;
my $InstanceID   = 0;
my $MetricID     = 0;
my $MetricTypeID = 90;
my $Factor       = 1;
my $Maximum      = 0;
my $Interval     = 300;
my $Error;

# Get the devices DeviceID, if it does not exist in the catalog it will be created
($Error, $Message, $DeviceID) = FindDeviceID({
    DBH         => \$RulesDBH, 
    StorageHash => $MetricHash, 
    DNS         => $Fields[1], 
    IP          => $Fields[2], 
    Create      => 1
});

# Create the Metric Instance
($Error, $Message, $InstanceID) = FindInstanceID({
    DBH         => \$RulesDBH, 
    StorageHash => $MetricHash, 
    Name        => $Fields[3], 
    DeviceID    => $DeviceID, 
    TypeID      => 0, 
    Create      => 1
});

# Create the Metric
($Error, $Message, $MetricID) = FindMetricID({
    DBH          => \$RulesDBH, 
    StorageHash  => $MetricHash, 
    DeviceID     => $DeviceID, 
    InstanceID   => $InstanceID, 
    MetricTypeID => $MetricTypeID, 
    Factor       => $Factor, 
    Max          => $Maximum, 
    PollInterval => $Interval, 
    Create       => 1
});

# Insert the metric in the queue to prepare for insertion
if (int($MetricID) > 0) {
    $DataQueue->enqueue($MetricID . ':' . $Fields[4] . ':' . $Fields[5] . ':' . $Fields[0]);
}

Administration Details

The following list shows the technical details needed for advanced administration of the application:

  • Package - coreCollection-app

  • Synopsis - ./FileCollectord [OPTIONS]

  • Option:

     -c, --AppConfigID N       Application Config ID (Service, Job, or Request ID)
     -?, -h, --Help            Print usage and exit
    
  • Threaded - Multi-Threaded