Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions services/alarm-logger/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Alarm Logging
# Alarm Logging Service

Logging alarm state and other messages to an elastic back end.
The alarm logging service (aka alarm-logger) records all alarm messages to create an archive of all alarm state changes and the associated actions.
This is an elasticsearch back end.

## Dependencies ##
1. Elasticsearch version 8.x OS specific release can be found here:
Expand Down Expand Up @@ -48,6 +49,11 @@ mvn spring-boot:run
Run with `-help` to see command line options,
including those used to create daily, weekly or monthly indices.

#### Standalone mode

With the `-standalone true` option on the command line or in `application.properties`, you can run the alarm logging service independently of an alarm server.
It may be useful to troubleshoot the system independently from production alarm services using the alarm log service backup for the long alarm log history.

#### Configuration

The alarm logger can be configured via command line switches when running the jar, see option `-help` for details,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private static void help()
System.out.println("-properties /opt/alarm_logger.properties - Properties file to be used (instead of command line arguments)");
System.out.println("-date_span_units M - Date units for the time based index to span.");
System.out.println("-date_span_value 1 - Date value for the time based index to span.");
System.out.println("-standalone false - Standalone Alarm Logger Service without Alarm (Kafka) Server");
System.out.println("-logging logging.properties - Load log settings");
System.out.println();
}
Expand Down Expand Up @@ -210,6 +211,14 @@ else if (cmd.equals("-date_span_value"))
properties.put("date_span_value",iter.next());
iter.remove();
}
else if (cmd.equals("-standalone"))
{
if (!iter.hasNext())
throw new Exception("Missing -standalone false or true");
iter.remove();
properties.put("standalone",iter.next());
iter.remove();
}
else if (cmd.equals("-logging"))
{
if (! iter.hasNext())
Expand Down Expand Up @@ -265,18 +274,29 @@ else if(cmd.equals("-thread_pool_size")){
final List<String> topicNames = Arrays.asList(properties.getProperty("alarm_topics").split(","));
logger.info("Starting logger for '..State': " + topicNames);

// Start a new stream consumer for each topic
topicNames.forEach(topic -> {
try
{
Scheduler.execute(new AlarmMessageLogger(topic));
Scheduler.execute(new AlarmCmdLogger(topic));
}
catch (Exception ex)
{
logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex);
}
});
final boolean standalone = Boolean.valueOf(properties.getProperty("standalone"));

// If the standalone is true, ignore the Schedulers for AlarmMessageLogger and AlarmCmdLogger
// otherwise run the Alarm Logger service as is.
if(standalone == true)
{
logger.info("We are in the Standalone Alarm Logger Service.");
}
else
{
// Start a new stream consumer for each topic
topicNames.forEach(topic -> {
try
{
Scheduler.execute(new AlarmMessageLogger(topic));
Scheduler.execute(new AlarmCmdLogger(topic));
}
catch (Exception ex)
{
logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex);
}
});
}

// Wait in command shell until closed
if(use_shell)
Expand All @@ -291,7 +311,9 @@ else if(cmd.equals("-thread_pool_size")){
Thread.currentThread().join();
}

close();
if(standalone == false){
close();
}
System.exit(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ date_span_units=M
# Size of the thread pool for message and command loggers. Two threads per topic/configuration are required
thread_pool_size=4

# Standalone - Alarm Logger Service
standalone=false

############################## REST Logging ###############################
# DEBUG level will log all requests and responses to and from the REST end points
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=INFO
Expand Down