Logstash scala log parsing - scala

I've got a problem with logstash. I use logback, logstash, kibana and elasticsearch (docker as logstash input source)
The problem is I have no idea how can I write a correct config file for logstash to get some interesting information.
The single scala log looks like this:
[INFO] [05/06/2016 13:58:31.789] [integration-akka.actor.default-dispatcher-14] [akka://integration/user/InstanceSupervisor/methodRouter/outDispatcher] sending msg: PublishMessage(instance,vouchers,Map(filePath -> /home/mateusz/JETBLUETESTING.csv, importedFiles -> Map(JETBLUETESTING.csv -> Map(status -> DoneStatus, processed -> 1, rows -> 5))),#contentHeader(content-type=application/octet-stream, content-encoding=null, headers=null, delivery-mode=2, priority=0, correlation-id=null, reply-to=null, expiration=null, message-id=null, timestamp=null, type=null, user-id=null, app-id=null, cluster-id=null)
I'd like to get something like tag [INFO], timestamp and of course the whole log in a single kibana result.
As for now i don't event know how exactly the log looks like (because its parsed by logback). Any information you can provide me would be greatly appreciated, because im stuck on this problem for few days.

When learning logstash it's best to find a debugger to help experiment (grok) with patterns. The standard appears to be hosted here. The site allows you to post a snippet from your logs, and then allows you to experiment with either pre-defined or custom patterns. The pre-defined patterns can be found here.
I had the same issue recently when trying to find out what logback was sending to logstash. I found that logback was able to convert the logs to json.A snippet I found useful is:
filter{
json{
source => "message"
}
}
Which I found in this related SO post
Once you can see the logs, it makes it much easier to experiment with patterns.
Hope this is useful.

Related

'rasa shell' does not intiate a chat session as expected

The command 'rasa shell' is supposed to start a chat session in the terminal itself upon its execution according to the documentation. But in my case, it's acting as given in the below image.
But the output is supposed to be a 2-way communication between the bot and the user as given below.
Your input -> hi
<Bot's response to 'hi'>
Your input -> something
<Bot's response to 'something'>
May I know what the reason for the above matter is? (Please note that I noticed a similar question to mine here). Since I found it not descriptive enough, I have posted this question.
Check if:
There aren't any redundant intent names in domain.yaml file.
There aren't any missing quotation marks in responses.

Jmx_exporter kafka config example question

Im looking at the example config for kafka in the official jmx_exporter repo
https://github.com/prometheus/jmx_exporter/blob/master/example_configs/kafka-2_0_0.yml
as well as the one from Kafka
https://github.com/confluentinc/cp-helm-charts/blob/master/charts/cp-kafka/templates/jmx-configmap.yaml
We can see things like
- pattern : kafka.server<type=ReplicaManager, name=(.+)><>(Value|OneMinuteRate)
name: "cp_kafka_server_replicamanager_$1"
- pattern : kafka.controller<type=KafkaController, name=(.+)><>Value
name: "cp_kafka_controller_kafkacontroller_$1"
- pattern : kafka.server<type=BrokerTopicMetrics, name=(.+)><>OneMinuteRate
name: "cp_kafka_server_brokertopicmetrics_$1"
My question concern Value, is it the name of an attribute that can be found on those Means identified by the following patterns kafka.server<type=ReplicaManager, name=(.+)>
I would imagine that OneMinuteRate is one. Although i could not find it in the list of metrics provided by Confluent: https://docs.confluent.io/current/kafka/monitoring.html. My guess was that, that metrics comes from an old version of kafka.
Hence, could someone let me know what Value is ?
Also, is there a place where i could find the official complete list of Kafka Mbeans ...
These metrics exist and are valid.
Value is one of the attributes of the kafka.server<type=ReplicaManager, name=(.+)> MBean when name is AtMinIsrPartitionCount for example.
OneMinuteRate is also a possible attribute on some of the names, for example when name is FailedIsrUpdatesPerSec.
The best way to find all these names is to use jsoncole. Upon starting, attach to the Kafka process and you can explore all the MBeans and find all attributes.

Log timestamp of an exception in Play?

I have some play code that calls some spark functions. Sometimes things break and I want a timestamp associated to the event. I currently get the error messages printed to STDOUT without a timestamp and am wondering if there's a way to configure the logger.xml to associate timestamps with these??
Providing your logger.xml file would have been helpful but anyways look for the "pattern" element for your STDOUT in the logger.xml file and change it by prepending the %d{ISO8601}
Check the logback configuration documentation for more information.
Logback Configuration

Perl parsing a log4j log [duplicate]

We have several applications that use log4j for logging. I need to get a log4j parser working so we can combine multiple log files and run automated analysis on them. I'm not looking to reinvent the wheel, so can someone point me to a decent pre-existing parser? I do have the log4j conversion pattern if that helps.
If not, I'll have to roll our own.
I didn't realize that Log4J ships with an XML appender.
Solution was: specify an XML appender in the logging configuration file, include that output XML file as an entity into a well formed XML file, then parse the XML using your favorite technique.
The other methods had the following limitations:
Apache Chainsaw - not automated enough
jdbc - poor performance in a high performance distributed app
You can use OtrosLogViewer with batch processing. You have to:
Define you log format, you can use Log4j pattern layout parser or Log4j XmlLayout
Create java class that implements LogDataParsedListener. Method public void logDataParsed(LogData data, BatchProcessingContext context) will be called on every parsed log event.
Create jar
Run OtrosLogViewer with specifying your log processing jar, LogDataParsedListener implementation and log files.
What you are looking for is called SawMill, or something like it.
Log4j log files aren't really suitable for parsing, they're too complex and unstructured. There are third party tools that can do it, I believe (e.g. Sawmill).
If you need to perform automated, custom analysis of the logs, you should consider logging to a database, and analysing that. JDBC ships with the JdbcAppender which appends all messages to a database of your choice, but it has performance implications, and it's a bit flaky. There are other, similar, alternatives on the interweb, though (like this one).
You -can- use Log4j's Chainsaw V2 to process the various log files and collect them into one table, and either output those events as xml or use Chainsaw's built-in expression-based filtering, searching & colorizing support to slice & dice the logs.
Steps:
- Start Chainsaw V2
- Create a chainsaw configuration file by copying the example configuration file available from the Welcome tab - define one LogFilePatternReceiver 'plugin' entry for each log file that you want to process
- Start Chainsaw with that configuration
- Each log file will end up as a separate tab in the UI
- Pause the chainsaw-log tab and clear the events from that tab
- Create a new tab which aggregates the events from the various tabs by going to the 'view, crate custom expression logpanel' menu item and enter 'level >= DEBUG' in the box. It will create a new tab containing events from all of the tabs with level >= debug (which is why you cleared the chainsaw-log tab).
You can get an overview of the expression syntax used to filter, colorize and search from the tutorial (available from the Help menu).
If you don't want to use Chainsaw, you can do something similar - start a simple app that doesn't log but loads a log4j.xml config file with the 'plugin' entries you defined for the Chainsaw configuration, but also define a FileAppender with an xmllayout - all of the events received by the 'receivers' will be sent to the single appender.

Trying to figure out what {s: ;} tags mean and where they come from

I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.