Configuring Metrics Reporting
By default, collection of metrics is enabled. This topic explains how to configure metrics to report to various output streams. You can output to the following destinations:
SLF4J — The SLF4J reporter outputs a plain text version of the metrics.The output file and the format of the data is controlled by a Logback configuration that coincides with the logger named in the reporter section.
Graphite API-based endpoint (like InfluxDB) — The group name of this metrics reporter section is called graphite.Define the frequency of collection and the endpoints to send the data to.This group can be enabled or disabled in isolation.
The Console — The data is output to the console of the machine that is running the Connection Server. When configuring this option, you also have the option to write to a file at the same time.
*.csv File — Each metric is written to a separate file. Potentially, ~130 files may be generated in a single-server ThingWorx environment. In a ThingWorx High Availability Clustering environment, the number of files is higher than ~130. The exact numbers depend on your environment.
Metrics configuration defines a set of one or more reporters that will receive metrics data, at a defined interval.The system outputs metrics data at every interval to all defined reporters.Each reporter can have its own interval defined (period_in_seconds property).
To change the default settings, you need to locate or add the metrics group to your configuration file for the Connection Server, define the reporters (where to send metrics), and make the necessary changes to the settings.
1. To define where you want to output metrics, configure one or more of the reporters groups:
To configure metrics to be sent to SLF4J, locate the reporters.slf4j group within the metrics group. Here are the default settings:

metrics {
reporters {
slf4j {
enabled = false
logger = "metrics"
period_in_seconds = 20
}
}
}
To configure the SLF4J destination, set the properties:
a. enabled — Change the value to true.
b. logger — Set the value to be the named logger that you have specified in your slf4j logback.xml file.
c. period_in_seconds — Set the number of seconds between each report of metrics. The default interval is 20 seconds.
If this group is the last in the reporters group and metrics group, be sure to add the closing curly braces (if not there already).
To configure all metrics to be sent to a Graphite API-based endpoint (like InfluxDB), locate or add the following graphite group to the reporters group, as follows:

metrics {
reporters {
graphite {
enabled = false
period_in_seconds = 5
endpoints = [{
host = "localhost"
port = 2003
}]
}
}
}
To configure the Graphite API-based endpoint (InfluxDB) option, set the properties of the graphite group and the endpoints group:
a. enabled — Change the value to true.
b. period_in_seconds — Change the number of seconds between each report of metrics, if desired. The default interval is 5 seconds.
c. endpoints.host — Specify the host name or IP address of the Graphite collector host machine (the InfluxDB host).
d. endpoints.port — Specify the number of the port that the collector is listening on for metric data. The default port is 2003.
If this group is the last in the reporters group and metrics group, be sure to add the closing curly braces (if not already present).
You can also configure metrics to be sent to the console of the machine where the Connection Server is running by adding the console group and properties to your configuration file (under the reporters group):

metrics {
reporters {
console {
enabled = false
period_in_seconds = 20
#Defaults to STDOUT
#outfile = "./connection-server_metrics.out"
}
}
}
To configure the console option (and optionally write to a file), set these properties:
a. enabled — Change the value to true.
b. period_in_seconds — Specify the number of seconds between each report of metrics. The default interval is 20 seconds.
c. Optionally, uncomment the outfile line and specify the location where you want to write the output. Note that relative paths are relative to the current working directory.
If this group is the last in the reporters group and metrics group, be sure to add the closing curly braces (if not already present).
To configure all metrics to be sent to a *.csv file, add the csv group to your configuration file (under the reporters group):

metrics {
reporters {
csv {
enabled = false
period_in_seconds = 20
outdir = "./connection-server_metrics_csvs"
}
}
}
To configure the csv option, set these properties:
a. enabled — Change the value to true.
b. period_in_seconds — Specify the number of seconds between each report of metrics. The default interval is 20 seconds. Keep in mind that the csv reporter creates one file per metric (approximately 130 files).
c. outdir — Specify the directory to use for storing the csv files.
You can use relative or absolute paths for the location. Relative paths are relative to the current working directory. The Connection Server will create this directory if it can. If not, a warning is written to the log and this reporter is disabled.
If this group is last in the reporters group and the metrics group, be sure to add the closing curly braces (if not already present).
2. Save and close the configuration file.
3. If you have not done so already, set the environment variable to point to your configuration file and your logback.xml file.
4. This step depends on whether you have previously started the Connection Server:
Previously started: Restart it for these configuration changes to take effect.
Not previously started: As long as you have set the environment variable, start the Connection Server.
Was this helpful?