Defining a new timestamp in Logstash










0















I'm trying to define a new timestamp in Logstash, in order to use the timestamp of the logs in my Kibana reportings instead of the Filebeat timestamp.



I had the following, which was working but didn't let me use the log timestamp as a time axis in Kibana:



grok {
match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"



So I modified it like this, but it's not working:



grok {
match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601:tstamp) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


date
match => ["tstamp", "TIMESTAMP_ISO8601"]



I tried to add what I think is a naming of the value inside of the Grok pattern (the ":tstamp" part), which I found here, and the define that as a date. But when I use that, I don't see any data in Kibana anymore.



I erased everything in Kibana in order to have a fresh start, and I deleted the "registry" file in Filebeat in order to make it stream the log file again.



What am I missing?



Edit: I was able to restore the data flow by changing my filters like that:



grok 
match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


date
match => ["tstamp", "ISO8601"]



But I still only see the @timestamp as Time Filter. tstamp is still considered as a string. I don't get it...










share|improve this question




























    0















    I'm trying to define a new timestamp in Logstash, in order to use the timestamp of the logs in my Kibana reportings instead of the Filebeat timestamp.



    I had the following, which was working but didn't let me use the log timestamp as a time axis in Kibana:



    grok {
    match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"



    So I modified it like this, but it's not working:



    grok {
    match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601:tstamp) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


    date
    match => ["tstamp", "TIMESTAMP_ISO8601"]



    I tried to add what I think is a naming of the value inside of the Grok pattern (the ":tstamp" part), which I found here, and the define that as a date. But when I use that, I don't see any data in Kibana anymore.



    I erased everything in Kibana in order to have a fresh start, and I deleted the "registry" file in Filebeat in order to make it stream the log file again.



    What am I missing?



    Edit: I was able to restore the data flow by changing my filters like that:



    grok 
    match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


    date
    match => ["tstamp", "ISO8601"]



    But I still only see the @timestamp as Time Filter. tstamp is still considered as a string. I don't get it...










    share|improve this question


























      0












      0








      0








      I'm trying to define a new timestamp in Logstash, in order to use the timestamp of the logs in my Kibana reportings instead of the Filebeat timestamp.



      I had the following, which was working but didn't let me use the log timestamp as a time axis in Kibana:



      grok {
      match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"



      So I modified it like this, but it's not working:



      grok {
      match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601:tstamp) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


      date
      match => ["tstamp", "TIMESTAMP_ISO8601"]



      I tried to add what I think is a naming of the value inside of the Grok pattern (the ":tstamp" part), which I found here, and the define that as a date. But when I use that, I don't see any data in Kibana anymore.



      I erased everything in Kibana in order to have a fresh start, and I deleted the "registry" file in Filebeat in order to make it stream the log file again.



      What am I missing?



      Edit: I was able to restore the data flow by changing my filters like that:



      grok 
      match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


      date
      match => ["tstamp", "ISO8601"]



      But I still only see the @timestamp as Time Filter. tstamp is still considered as a string. I don't get it...










      share|improve this question
















      I'm trying to define a new timestamp in Logstash, in order to use the timestamp of the logs in my Kibana reportings instead of the Filebeat timestamp.



      I had the following, which was working but didn't let me use the log timestamp as a time axis in Kibana:



      grok {
      match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"



      So I modified it like this, but it's not working:



      grok {
      match => "message" => "(?<timestamp>%TIMESTAMP_ISO8601:tstamp) %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


      date
      match => ["tstamp", "TIMESTAMP_ISO8601"]



      I tried to add what I think is a naming of the value inside of the Grok pattern (the ":tstamp" part), which I found here, and the define that as a date. But when I use that, I don't see any data in Kibana anymore.



      I erased everything in Kibana in order to have a fresh start, and I deleted the "registry" file in Filebeat in order to make it stream the log file again.



      What am I missing?



      Edit: I was able to restore the data flow by changing my filters like that:



      grok 
      match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


      date
      match => ["tstamp", "ISO8601"]



      But I still only see the @timestamp as Time Filter. tstamp is still considered as a string. I don't get it...







      logging timestamp logstash elastic-stack logstash-grok






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 17:24







      Alexis Dufrenoy

















      asked Nov 14 '18 at 14:37









      Alexis DufrenoyAlexis Dufrenoy

      8,121960117




      8,121960117






















          1 Answer
          1






          active

          oldest

          votes


















          0














          There were actually 2 distinct problems in what I made.



          As I indicated my edit of the question, the date filter was wrong. I had to use



          match => ["tstamp", "ISO8601"]


          with "ISO8601" instead of "TIMESTAMP_ISO8601".



          At that point, things were actually working, even if it wasn't obvious, because by default, Logstash overwrites the value of @timestamp with the result of the date filter. To avoid that, I had to use the target option:



          target => "logdate"


          I now have a logdate field in Kibana, of type date and I can select it as time filter when creating a pattern.



          So my final filters in Logstash look like that:



          grok 
          match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


          date
          match => ["tstamp", "ISO8601"]
          target => "logdate"






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302681%2fdefining-a-new-timestamp-in-logstash%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            There were actually 2 distinct problems in what I made.



            As I indicated my edit of the question, the date filter was wrong. I had to use



            match => ["tstamp", "ISO8601"]


            with "ISO8601" instead of "TIMESTAMP_ISO8601".



            At that point, things were actually working, even if it wasn't obvious, because by default, Logstash overwrites the value of @timestamp with the result of the date filter. To avoid that, I had to use the target option:



            target => "logdate"


            I now have a logdate field in Kibana, of type date and I can select it as time filter when creating a pattern.



            So my final filters in Logstash look like that:



            grok 
            match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


            date
            match => ["tstamp", "ISO8601"]
            target => "logdate"






            share|improve this answer





























              0














              There were actually 2 distinct problems in what I made.



              As I indicated my edit of the question, the date filter was wrong. I had to use



              match => ["tstamp", "ISO8601"]


              with "ISO8601" instead of "TIMESTAMP_ISO8601".



              At that point, things were actually working, even if it wasn't obvious, because by default, Logstash overwrites the value of @timestamp with the result of the date filter. To avoid that, I had to use the target option:



              target => "logdate"


              I now have a logdate field in Kibana, of type date and I can select it as time filter when creating a pattern.



              So my final filters in Logstash look like that:



              grok 
              match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


              date
              match => ["tstamp", "ISO8601"]
              target => "logdate"






              share|improve this answer



























                0












                0








                0







                There were actually 2 distinct problems in what I made.



                As I indicated my edit of the question, the date filter was wrong. I had to use



                match => ["tstamp", "ISO8601"]


                with "ISO8601" instead of "TIMESTAMP_ISO8601".



                At that point, things were actually working, even if it wasn't obvious, because by default, Logstash overwrites the value of @timestamp with the result of the date filter. To avoid that, I had to use the target option:



                target => "logdate"


                I now have a logdate field in Kibana, of type date and I can select it as time filter when creating a pattern.



                So my final filters in Logstash look like that:



                grok 
                match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


                date
                match => ["tstamp", "ISO8601"]
                target => "logdate"






                share|improve this answer















                There were actually 2 distinct problems in what I made.



                As I indicated my edit of the question, the date filter was wrong. I had to use



                match => ["tstamp", "ISO8601"]


                with "ISO8601" instead of "TIMESTAMP_ISO8601".



                At that point, things were actually working, even if it wasn't obvious, because by default, Logstash overwrites the value of @timestamp with the result of the date filter. To avoid that, I had to use the target option:



                target => "logdate"


                I now have a logdate field in Kibana, of type date and I can select it as time filter when creating a pattern.



                So my final filters in Logstash look like that:



                grok 
                match => "message" => "%TIMESTAMP_ISO8601:tstamp %LOGLEVEL:loglevel (?<class>[A-Za-z0-9$_.]+) %NOTSPACE:method(%JAVAFILE:class:%NONNEGINT:line) %GREEDYDATA:message$"


                date
                match => ["tstamp", "ISO8601"]
                target => "logdate"







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 15 '18 at 9:25

























                answered Nov 14 '18 at 17:02









                Alexis DufrenoyAlexis Dufrenoy

                8,121960117




                8,121960117





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302681%2fdefining-a-new-timestamp-in-logstash%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3