How to flatten json properties to _source used ELK?How does database indexing work?How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to make a flat list out of list of listsWhy does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Merge/flatten an array of arrays

How can I discourage sharing internal API keys within a company?

Why is the T-1000 humanoid?

Why is the Digital 0 not 0V in computer systems?

Can I toggle Do Not Disturb on/off on my Mac as easily as I can on my iPhone?

How to stabilise the bicycle seatpost and saddle when it is all the way up?

Diffraction of a wave passing through double slits

What does a Light weapon mean mechanically?

Sort files in a given folders and provide as a list

What is and what isn't ullage in rocket science?

How do I say "quirky" in German without sounding derogatory?

How are aircraft depainted?

What exactly is a marshrutka (маршрутка)?

My research paper filed as a patent in China by my Chinese supervisor without me as inventor

How do email clients "send later" without storing a password?

Can I conceal an antihero's insanity - and should I?

Parallel resistance in electric circuits

How would you control supersoldiers in a late iron-age society?

Confirm the ending of a string

POSIX compatible way to get user name associated with a user ID

What is the derivative of an exponential function with another function as its base?

Were Roman public roads build by private companies?

Why is this weapon searching for a new owner?

How are unbalanced coaxial cables used for broadcasting TV signals without any problems?

Why is template constructor preferred to copy constructor?



How to flatten json properties to _source used ELK?


How does database indexing work?How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to make a flat list out of list of listsWhy does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Merge/flatten an array of arrays






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Suppose I have these 2 log messages send to logstash/elasticsearch:




"events": [

"Message": "Get all motors",
"Level": "Information"
,

"Message": "Get all motors",
"Level": "Information"

]



The expected search result:



"hits" : 
"total" : 2,
"max_score" : 1.0,
"hits" : [

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1",
"Message" : "Get all motors",
"Level" : "Information"

,

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1",
"Message" : "Get all motors",
"Level" : "Information"


]



I used below logstash config:



# Http input listening port 8080
input
http
#default host 0.0.0.0:8080
codec => json



# Separate the logs
filter
split
field => "events"
target => "e"


mutate
remove_field => ["events", "headers"]



# Send the logs to Elasticsearch
output
elasticsearch
hosts => "localhost:9200"
index=>"mylog-%+YYYY.MM.dd"
document_type => "log"




The actual search result:



"hits" : 
"total" : 2,
"max_score" : 1.0,
"hits" : [

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1",
"e" :
"Message" : "Get all motors",
"Level" : "Information"


,

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1",
"e" :
"Message" : "Get all motors",
"Level" : "Information"



]



The different is:



  • In the actual result, my log info is nested in e property

  • I want all the log info props flattened (direct children of _source)

Elasticsearch document suggest remove target from filter:



filter 
split
field => "events"




But if I do that, my result will be empty:



"hits" : 
"total" : 2,
"max_score" : 1.0,
"hits" : [

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1"

,

"_source" :
"@timestamp" : "2019-03-28T10:05:05.649Z",
"@version" : "1"


]



How can I achieve the expected result?



My environment:



  • Windows 10 x64 Pro

  • ELK 6.7

  • JDK 8u201









share|improve this question
































    0















    Suppose I have these 2 log messages send to logstash/elasticsearch:




    "events": [

    "Message": "Get all motors",
    "Level": "Information"
    ,

    "Message": "Get all motors",
    "Level": "Information"

    ]



    The expected search result:



    "hits" : 
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1",
    "Message" : "Get all motors",
    "Level" : "Information"

    ,

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1",
    "Message" : "Get all motors",
    "Level" : "Information"


    ]



    I used below logstash config:



    # Http input listening port 8080
    input
    http
    #default host 0.0.0.0:8080
    codec => json



    # Separate the logs
    filter
    split
    field => "events"
    target => "e"


    mutate
    remove_field => ["events", "headers"]



    # Send the logs to Elasticsearch
    output
    elasticsearch
    hosts => "localhost:9200"
    index=>"mylog-%+YYYY.MM.dd"
    document_type => "log"




    The actual search result:



    "hits" : 
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1",
    "e" :
    "Message" : "Get all motors",
    "Level" : "Information"


    ,

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1",
    "e" :
    "Message" : "Get all motors",
    "Level" : "Information"



    ]



    The different is:



    • In the actual result, my log info is nested in e property

    • I want all the log info props flattened (direct children of _source)

    Elasticsearch document suggest remove target from filter:



    filter 
    split
    field => "events"




    But if I do that, my result will be empty:



    "hits" : 
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1"

    ,

    "_source" :
    "@timestamp" : "2019-03-28T10:05:05.649Z",
    "@version" : "1"


    ]



    How can I achieve the expected result?



    My environment:



    • Windows 10 x64 Pro

    • ELK 6.7

    • JDK 8u201









    share|improve this question




























      0












      0








      0








      Suppose I have these 2 log messages send to logstash/elasticsearch:




      "events": [

      "Message": "Get all motors",
      "Level": "Information"
      ,

      "Message": "Get all motors",
      "Level": "Information"

      ]



      The expected search result:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "Message" : "Get all motors",
      "Level" : "Information"

      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "Message" : "Get all motors",
      "Level" : "Information"


      ]



      I used below logstash config:



      # Http input listening port 8080
      input
      http
      #default host 0.0.0.0:8080
      codec => json



      # Separate the logs
      filter
      split
      field => "events"
      target => "e"


      mutate
      remove_field => ["events", "headers"]



      # Send the logs to Elasticsearch
      output
      elasticsearch
      hosts => "localhost:9200"
      index=>"mylog-%+YYYY.MM.dd"
      document_type => "log"




      The actual search result:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "e" :
      "Message" : "Get all motors",
      "Level" : "Information"


      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "e" :
      "Message" : "Get all motors",
      "Level" : "Information"



      ]



      The different is:



      • In the actual result, my log info is nested in e property

      • I want all the log info props flattened (direct children of _source)

      Elasticsearch document suggest remove target from filter:



      filter 
      split
      field => "events"




      But if I do that, my result will be empty:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1"

      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1"


      ]



      How can I achieve the expected result?



      My environment:



      • Windows 10 x64 Pro

      • ELK 6.7

      • JDK 8u201









      share|improve this question
















      Suppose I have these 2 log messages send to logstash/elasticsearch:




      "events": [

      "Message": "Get all motors",
      "Level": "Information"
      ,

      "Message": "Get all motors",
      "Level": "Information"

      ]



      The expected search result:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "Message" : "Get all motors",
      "Level" : "Information"

      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "Message" : "Get all motors",
      "Level" : "Information"


      ]



      I used below logstash config:



      # Http input listening port 8080
      input
      http
      #default host 0.0.0.0:8080
      codec => json



      # Separate the logs
      filter
      split
      field => "events"
      target => "e"


      mutate
      remove_field => ["events", "headers"]



      # Send the logs to Elasticsearch
      output
      elasticsearch
      hosts => "localhost:9200"
      index=>"mylog-%+YYYY.MM.dd"
      document_type => "log"




      The actual search result:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "e" :
      "Message" : "Get all motors",
      "Level" : "Information"


      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1",
      "e" :
      "Message" : "Get all motors",
      "Level" : "Information"



      ]



      The different is:



      • In the actual result, my log info is nested in e property

      • I want all the log info props flattened (direct children of _source)

      Elasticsearch document suggest remove target from filter:



      filter 
      split
      field => "events"




      But if I do that, my result will be empty:



      "hits" : 
      "total" : 2,
      "max_score" : 1.0,
      "hits" : [

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1"

      ,

      "_source" :
      "@timestamp" : "2019-03-28T10:05:05.649Z",
      "@version" : "1"


      ]



      How can I achieve the expected result?



      My environment:



      • Windows 10 x64 Pro

      • ELK 6.7

      • JDK 8u201






      json indexing elastic-stack flatten






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 11:59







      Tuyen Pham

















      asked Mar 28 at 10:29









      Tuyen PhamTuyen Pham

      4,87610 gold badges44 silver badges85 bronze badges




      4,87610 gold badges44 silver badges85 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          remove the target => "e" part, your target is the root of the document.






          share|improve this answer

























          • I tried that. If I remove it, the log info will not be recorded at all

            – Tuyen Pham
            Mar 28 at 10:39











          • Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

            – Vincent Chalmel
            Mar 28 at 13:24










          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/4.0/"u003ecc by-sa 4.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%2f55395337%2fhow-to-flatten-json-properties-to-source-used-elk%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
















          remove the target => "e" part, your target is the root of the document.






          share|improve this answer

























          • I tried that. If I remove it, the log info will not be recorded at all

            – Tuyen Pham
            Mar 28 at 10:39











          • Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

            – Vincent Chalmel
            Mar 28 at 13:24















          0
















          remove the target => "e" part, your target is the root of the document.






          share|improve this answer

























          • I tried that. If I remove it, the log info will not be recorded at all

            – Tuyen Pham
            Mar 28 at 10:39











          • Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

            – Vincent Chalmel
            Mar 28 at 13:24













          0














          0










          0









          remove the target => "e" part, your target is the root of the document.






          share|improve this answer













          remove the target => "e" part, your target is the root of the document.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 10:31









          Vincent ChalmelVincent Chalmel

          3342 silver badges14 bronze badges




          3342 silver badges14 bronze badges















          • I tried that. If I remove it, the log info will not be recorded at all

            – Tuyen Pham
            Mar 28 at 10:39











          • Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

            – Vincent Chalmel
            Mar 28 at 13:24

















          • I tried that. If I remove it, the log info will not be recorded at all

            – Tuyen Pham
            Mar 28 at 10:39











          • Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

            – Vincent Chalmel
            Mar 28 at 13:24
















          I tried that. If I remove it, the log info will not be recorded at all

          – Tuyen Pham
          Mar 28 at 10:39





          I tried that. If I remove it, the log info will not be recorded at all

          – Tuyen Pham
          Mar 28 at 10:39













          Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

          – Vincent Chalmel
          Mar 28 at 13:24





          Sorry, I was not clear enough, don't remove the line, but make it target the root of the document, not "e"

          – Vincent Chalmel
          Mar 28 at 13:24








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          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%2f55395337%2fhow-to-flatten-json-properties-to-source-used-elk%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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현