Merge Multiple Values into a Single Field

Comments

8 comments

  • Avatar
    Joseph Plunkett

    I got this figured out and I'll post the answer here in case it helps someone else. 

     

    _sourceCategory=<YourSrcCategoryHere>
    | count dst_ip, dst_port  // this dedupes the values
    | now() as _messagetime  //Need this for transactionize
    | transactionize dst_ip (merge dst_ip takeFirst, dstport join with ", ") //Formats the table
    | fields - _messagetime

     

     

    1
    Comment actions Permalink
  • Avatar
    Shanmukhanand Naikwade

    Hi Joseph,
    I am struggling with the same scenario. However, dstport join with ", " displays all the duplicate values as well. To qoute your example here.

    It gives us the result as  - 

    IP Address      |    Ports
    ---------------------------------
    8.8.8.8             | 80, 443, 443, 80, 80, 80
    192.168.1.1     | 22, 443, 25, 22, 22

     

    In short, it does not remove the duplicates from the result. Do you know how we can remove these duplicate values and have only unique values here?

    0
    Comment actions Permalink
  • Avatar
    Joseph Plunkett

    Shanmukhanand Naikwade

    Yes, in order to remove duplicates you can do a couple things. First, you can 'count' the ports before the transactionize OR you can use the 'takeFirst' param in the transactionize statement. 

    If you are still having trouble post your query and I will look at it. 

    0
    Comment actions Permalink
  • Avatar
    Shanmukhanand Naikwade

    'takeFirst' is not the best solution available because, from the row line "8.8.8.8             | 80, 443, 443, 80, 80, 80" It will only capture 80 and not 443. 

    After a lot of research i think there is no solution in Sumo logic, which is kinda of frustrating 

    0
    Comment actions Permalink
  • Avatar
    Joseph Plunkett

    Shanmukhanand Naikwade

    Ahh yeah I see what you're saying. You need to do a count before the transactionize to dedup the ports. 

    It is possible I do have this working, it just isn't clean. 

    0
    Comment actions Permalink
  • Avatar
    Shanmukhanand Naikwade

    can you please share your query?

    0
    Comment actions Permalink
  • Avatar
    Joseph Plunkett

    Shanmukhanand Naikwade

    | _sourceCategory=<srcCat>

    | count dst_ip, dst_port
    | now() as _messagetime
    | transactionize dst_ip (merge dst_ip takeFirst, dst_port join with ", ") 
    | fields - _messagetime

     

    // Output will be: 

    dst_ip | dst_port

    1.1.1.1 | 443, 80

    0
    Comment actions Permalink
  • Avatar
    Shanmukhanand Naikwade

    ok. thank you 

    0
    Comment actions Permalink

Please sign in to leave a comment.