hi,
i am trying to work with grok, but i am failing.
my need:
parse frequently a file, which is written newly (so no “tail” needed).
within this file i use grok pattern to extract informations.
how would it be possible to get the linebreaks removed to get all information in one? with several grok patterns i get several data which will be inserted to the database (influxdb).
i have issues in getting the timestamp converted in to unix_timestamp. I tried using this custom grok pattern:
MYTS %{DATE_EU}.%{TIME}
and this grpk_pattern:
"\\sStamp_Created\\s=\\s%{MYTS:mytimestamp}.ID.*"
output:
mytimestamp=“04.10.2021|17:33:35”
when i try to convert that to another timestamp, i get an error message:
Error parsing timestamp [04.10.2021|17:33:35], could not find any suitable time layouts.
Hi @astrakid, I am sorry to hear you are having a hard time with this. Will you please post your config file so I can run it and mess with it on my end? Have you tried taking a look at this thread?
unfortunately not. I neither get “no match found” nor a hit. It seems to be ignored. Might due to the “|” in the string? Is it necessary too escape the pipe?
@astrakid This is a grok formatting question at this point. I would suggest trying out different paterns using something like this online grok tool until you get what you are after.
For example if your timestamp field looked like:
Stamp_Created = 2017-03-11T19:23:34.000+00:00
the grok pattern would be:
Stamp_Created = %{TIMESTAMP_ISO8601:timestamp}
In your case, you have an entirely custom format. Therefore, you need a custom pattern. Here is from your original example:
yes, that goes into the right direction.
i only get the keys for explicit mentioned variables (in this case “year” and “time”).
when i add variable names to MONTHDAY and MONTHNUM, I get those as well. ok, i can handle that.
maybe you can guide me how to convert thiese infos into a simple timestamp for influxdb now? i want to get oldest and youngest information. let me explain:
for current timestamp 29.10.2021 07:47 telegraf is getting information from the files, e.g.:
agrotimestamp=27.10.2021 21:10
i want to have this information in influxdb-datapoint with current timestamp and as further information the “agrotimestamp”. when i have different agrotimestamps at current timestamp in influxdb, i want to show the youngest and oldest agrotimestamps for this point.
kind regards and thanks for solving the main issue here!