Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Hostnames, IP Addresses, Ports
  • Accounts
  • Database Names

There are situations when where log files should be anonymized before forwarding to a 3rd party, to the SOS Ticketing System or to a public forum to receive community support.

...

Anonymization is available from a Java class and is invoked from by a shell script available at the following default locations:

...

Code Block
titleInvocation of Log Anonymizer Script
Usage: loganonymize-anonymizerlogs.sh [Options]

  Options:
    -l | --log-file=<log-file>       | optional: location of log files to be anonymized; a single file, directory or wildcards can be specified;
                                                 the argument can occur any number of times
    -o | --output-dir=<directory>    | optional: output directory for anonymized log files
    -r | --rules-file=<rules-file>   | optional: path to a YAML file holding rules for anonymization; by default built-in rules will be applied
    -e | --export-rules=<rules-file> | optional: path to a YAML file to which built-in rules will be exported

...

  • Options
    • -l | --log-file=<log-file>: Specifies the location of a the log file(s) to be anonymized.
      • This option can be specified repeatedly for a number of files. Wildcards can be specified and directories can be specified if all included files are to be anonymized.
      • Plain text log files with the .log file extension and compressed log files with the .gz file extension are considered - see the JS7 - Log Rotation article.
      • Anonymized log file names are prefixed with the string: anonymized- 
      • By default anonymized log files are stored in the directory in which original log files are found.
    • -o | --output-dir=<directory>: Optionally specifies the output directory in which anonymized log files are to be stored. If this argument is omitted then anonymized log files are stored in their original directory.
    • -r | --rules-file=<rules-file>: Optionally specifies the location of a file in YAML format that holds the rules to be applied for anonymization.
    • -e | --export-rules=<rules-file>: Optionally specifies the location of a file in YAML format to which the built-in rules for anonymization will be exported.

...

Code Block
titleExample for Invocation of Log Anonymizer Script
loganonymize-anonymizerlogs.sh --log-file=/var/sos-berlin.com/js7/controller/logs/controller.log

...

Code Block
titleExample for Invocation of Log Anonymizer Script for a number of Log Files
loganonymize-anonymizerlogs.sh --log-file=/var/sos-berlin.com/js7/joc/logs/joc.log  \
                  --log-file=/var/sos-berlin.com/js7/joc/logs/joc-debug.log \
                  --output-dir=/tmp/logs

...

Code Block
titleExample for Invocation of Log Anonymizer Script with Wildcards for Log Files
loganonymize-anonymizerlogs.sh --log-file=/var/sos-berlin.com/js7/joc/logs/joc*  \
                  --output-dir=/tmp/logs

...

  • Creates anonymized versions of the log files indicated from the given directory. The wildcard specifies any log files carrying a name that starts with joc will be used.
  • The wildcard includes consideration of plain text log files available with the .log file extension and also consideration of compressed log files which are available with a .gz file extension.
  • Anonymized log files are stored in the output directory.

...

Code Block
titleExample for Export of Rules to a File
loganonymize-anonymizerlogs.sh --export-rules=/tmp/rules.yaml

...

Code Block
titleExample for Invocation of Log Anonymizer Script with individual Rules from a File
loganonymize-anonymizerlogs.sh --log-file=/var/sos-berlin.com/js7/agent_4445/logs/*.log \
                  --output-dir=/tmp/logs \
                  --rules-file=/tmp/rules.yaml

...

Users who wish to run the Log Anonymizer outside of a JS7 installation can:

  • copy a number of Java related files as available from the Controller or Agent installation,
  • create a shell script to invoke the Log Anonymizer.

Java related Files required by Log Anonymizer

The following files can be found from in a Controller or Agent installation for Unix or Windows.

  • Note that version numbers of binary files can change over time. The examples below examples assume binary Java related files as provided with Release 2.4.0.
  • Users can copy the following Java related files from the ./lib/3rd-party, ./lib/sos, ./lib/stdout directories to the location from which where they want to use Log Anonymizer:

Code Block
titleJava binary files required by Log Anonymizer
linenumberstrue
./lib/sos/sos-commons-util-2.4.0.jar
./lib/stdout/log4j2.xml
./lib/3rd-party/commons-io-2.7.jar
./lib/3rd-party/org.apache.logging.log4j.log4j-api-2.17.2.jar
./lib/3rd-party/org.apache.logging.log4j.log4j-core-2.17.2.jar
./lib/3rd-party/org.apache.logging.log4j.log4j-slf4j-impl-2.17.2.jar
./lib/3rd-party/org.slf4j.slf4j-api-1.7.36.jar
./lib/3rd-party/snakeyaml-1.30.jar

...

The directory hierarchy is assumed like this:

  • loganonymize-anonymizerlogs.sh | .cmd
    • lib
      • sos
        • sos-commons-util-2.4.0.jar
      • stdout
        • log4j2.xml
      • 3rd-partycommons-io-2.7.jar
        • org.apache.logging.log4j.log4j-api-2.17.2.jar
        • org.apache.logging.log4j.log4j-core-2.17.2.jar
        • org.apache.logging.log4j.log4j-slf4j-impl-2.17.2.jar
        • org.slf4j.slf4j-api-1.7.36.jar
        • snakeyaml-1.30.jar

...