Skip to content

Logging & Monitoring

Andreas Schwarte edited this page Apr 8, 2019 · 3 revisions

Logging

FedX does not rely on a specific logging backend implementation at runtime, however, it ships with a pre-defined Log4J 2 configuration (e.g. for the CLI).

To integrate with other logging backends it is possible to use any of the SLF4J adapters.

See also etc/log4j.properties for the configuration of expected loggers, particularly for the query log.

Monitoring

FedX brings certain facilities to monitor the application state. These facilities are described in the following.

Note: for the following features enableMonitoring must be set in the FedX configuration.

Logging queries

By setting monitoring.logQueryPlan=true in the FedX configuration, all incoming queries are traced to logs/queryLog.log. For logging the QueryLog service is used, which internally applies log4j features.

Logging the query plan

There are two ways of seeing the optimized query plan:

a) by setting debugQueryPlan=true, the query plan is printed to stdout (which is handy in the CLI or for debugging).

b) by setting monitoring.logQueryPlan=true the optimized query plan is written to a variable local to the executing thread.The optimized query plan can be retrieved via the QueryPlanLog service, as illustrated in the following abstract snippet.

Config.initialize();
Config.getConfig().set("enableMonitoring", "true");
Config.getConfig().set("monitoring.logQueryPlan", "true");
Repository repo = FedXFactory.initializeFederation("local/dataSourceConfig.ttl");

TupleQuery query = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, <SOME_QUERY>);
.. evaluate query ..

System.out.println("# Optimized Query Plan:");
System.out.println(QueryPlanLog.getQueryPlan());

Monitoring the number of requests

If monitoring is enabled, the number of requests sent to each individual federation member are monitored. All available information can be retrieved by the MonitoringService, which can be retrieved via

MonitoringUtil.getMonitoringService()

The following snippet illustrates a monitoring utility that prints all monitoring information to stdout.

Config.initialize();
Config.getConfig().set("enableMonitoring", "true");
Config.getConfig().set("monitoring.logQueryPlan", "true");
SailRepository repo = FedXFactory.initializeFederation("local/dataSourceConfig.ttl");

TupleQuery query = ...

.. evaluate queries ..

MonitoringUtil.printMonitoringInformation();