<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting unique IDs into chart column names in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454931#M128707</link>
    <description>&lt;P&gt;Renjith, thanks very much for such a supremely detailed answer. I came across streamstats on Friday evening and thought that would present a way forward - you've really helped me accelerate towards achieving what I need to!  I do also think the events we are generating and the data we are indexing could do with some revision, which would make life easier...  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2019 08:52:54 GMT</pubDate>
    <dc:creator>jimmymccauley</dc:creator>
    <dc:date>2019-03-25T08:52:54Z</dc:date>
    <item>
      <title>Converting unique IDs into chart column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454929#M128705</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;

&lt;P&gt;This is my second SOS this week as I get acquainted with Splunk. I've exhausted all possibilities trying to solve this problem... I'm part way there and I'd hoping someone can provide inspiration or enlightenment.&lt;/P&gt;

&lt;P&gt;I'm attempting to create a dashboard that shows the build outcome for a number of services over the last 5 builds executed.&lt;BR /&gt;
The query I use to extract and tabulate the raw data is as follows:&lt;BR /&gt;
&lt;CODE&gt;index="osesat-dev-01" source=fluentd environment="test-b" platform_region="eu-west-1" kubernetes.pod_name="trufflehog*" OR kubernetes.pod_name="sat-ctrlr-*" app_name=* request_uuid="*" &lt;BR /&gt;
| rex field=artifact_source ".*/(?.*)" &lt;BR /&gt;
| fields - _raw &lt;BR /&gt;
| fields _time, request_uuid, app_name, svc_name, artifact_source, artifact_branch, build_id, kubernetes.pod_name, test_type, test_tool&lt;BR /&gt;
| join request_uuid [search index="osesat-dev-01" source=fluentd environment="test-b" platform_region="eu-west-1" request_uuid="*" kubernetes.pod_name="trufflehog*" OR kubernetes.pod_name="sat-ctrlr-*" result="success" OR result="fail" &lt;BR /&gt;
    | fields - _raw &lt;BR /&gt;
    | fields _time, request_uuid, artifact_source, artifact_branch, build_id, result, kubernetes.pod_name, report, "High Entropy count"] &lt;BR /&gt;
| dedup 5 app_name&lt;BR /&gt;
| table app_name, svc_name, build_id, result &lt;BR /&gt;
| sort -time&lt;/CODE&gt;   &lt;/P&gt;

&lt;P&gt;My problem is when it comes to charting the 5 most recent builds. I'd like 5 columns called:&lt;BR /&gt;
 "Latest Build", "Latest Build -1"....... "Latest Build -4".&lt;BR /&gt;
Under each of these columns, we'd see a 'Success' or 'Fail' status with a separate row for each service.&lt;/P&gt;

&lt;P&gt;However the Build ID fields contain Build IDs specific to each service e.g. 5 most recent builds for service 1 and service 2 could be as follows:&lt;BR /&gt;
Service 1: Build 119, Build 118, Build 117, Build 116, Build 115&lt;BR /&gt;
Serivce 2: Build 20, Build 19, Build 18, Build 17, Build 16&lt;/P&gt;

&lt;P&gt;I am having a lot of difficultly trying to reconcile the unique Build IDs to the 5 columns representing the most recent build history.&lt;/P&gt;

&lt;P&gt;When I use "Chart over by" or "xyseries" I get 10 columns if I chart the Service 1 and Service 2 example above - I can't figure out how to rename the columns.&lt;BR /&gt;
When I use "transpose", I can rename the columns; I can get the outcome I want when I report build history against a single service, but I have problems when I try to chart build history for multiple services. &lt;/P&gt;

&lt;P&gt;Please see the below which provides an overview of the &lt;STRONG&gt;data table&lt;/STRONG&gt; produced&lt;BR /&gt;
Service Name | Build ID  | Build Status &lt;BR /&gt;
--------------------|------------|--------------&lt;BR /&gt;
webgoat      | Build 20  | fail&lt;BR /&gt;&lt;BR /&gt;
webgoat      | Build 19  | success&lt;BR /&gt;&lt;BR /&gt;
webgoat      | Build 18  | fail&lt;BR /&gt;&lt;BR /&gt;
webgoat      | Build 17  | fail&lt;BR /&gt;&lt;BR /&gt;
webgoat      | Build 16  | fail&lt;BR /&gt;&lt;BR /&gt;
pipeline-svc | Build 119 | success&lt;BR /&gt;&lt;BR /&gt;
pipeline-svc | Build 118 | success&lt;BR /&gt;&lt;BR /&gt;
pipeline-svc | Build 117 | fail&lt;BR /&gt;&lt;BR /&gt;
pipeline-svc | Build 116 | fail&lt;BR /&gt;&lt;BR /&gt;
pipeline-svc | Build 115 | success      &lt;/P&gt;

&lt;P&gt;Any workarounds greatly appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;jimmy&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 14:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454929#M128705</guid>
      <dc:creator>jimmymccauley</dc:creator>
      <dc:date>2019-03-22T14:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Converting unique IDs into chart column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454930#M128706</link>
      <description>&lt;P&gt;@jimmymccauley ,&lt;/P&gt;

&lt;P&gt;Looking at your search, not quite sure why you need a join since both searches in the join have similar search terms. Most probably your existing search could be rewritten as below. Please have a look and see if it yields the same result &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="osesat-dev-01" source=fluentd environment="test-b" platform_region="eu-west-1" request_uuid="*" 
 kubernetes.pod_name="trufflehog*" OR kubernetes.pod_name="sat-ctrlr-*" result="success" OR result="fail" 
 |fields _time, app_name, svc_name, build_id, result | sort -time|dedup 5 app_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Coming back to the original question, try adding the below search to your original search.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;version 1&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |untable svc_name,build_id,result | eval buildNo=if(match(result,"build*"),result,null())|filldown buildNo
 |streamstats count by svc_name|eval buildName=if(count%2==0,"Build".(count-1),"Build".count)
 |chart values(status) over svc by buildName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you really want to split the rows for build id and status instead of multivalue field, try this version&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Version 2&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |untable svc_name,build_id,result | eval buildNo=if(match(result,"build*"),result,null())|filldown buildNo
 |streamstats count by svc_name|eval buildName=if(count%2==0,"Build".(count-1),"Build".count)
 |chart values(status) over svc by buildName
 |eval z=mvzip(mvzip(mvzip(mvzip(Build1,Build3),Build5),Build7),Build9)|fields svc,z|mvexpand z
 |rex field=z "(?&amp;lt;LatestBuild&amp;gt;\w+),(?&amp;lt;LatestBuild_1&amp;gt;\w+),(?&amp;lt;LatestBuild_2&amp;gt;\w+),(?&amp;lt;LatestBuild_3&amp;gt;\w+),(?&amp;lt;LatestBuild_4&amp;gt;\w+)"
 |fields - z   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample data and search used to test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval svc_name="webgoat webgoat webgoat webgoat webgoat pipeline-svc pipeline-svc pipeline-svc  pipeline-svc pipeline-svc"|makemv svc_name|mvexpand svc_name
|appendcols [| makeresults |eval build_id="build_id20 build_id19 build_id18 build_id17 build_id16 build_id119 build_id118 build_id117 build_id116 build_id115"|makemv build_id| mvexpand build_id]
|appendcols [|makeresults |eval result="fail success fail fail fail success success fail fail success" | makemv result|mvexpand result]
|table svc_name,build_id,result
|rename COMMENT as "&amp;lt;--Until here is dummy data generation and has nothing to do with original search--&amp;gt;"
|untable  svc_name,build_id,result|eval build_idno=if(match(result,"build_id*"),result,null())|filldown build_idno
|streamstats count by svc_name|eval build_idName=if(count%2==0,"build_id".(count-1),"build_id".count)
|chart values(result) over svc_name by build_idName
|eval z=mvzip(mvzip(mvzip(mvzip(build_id1,build_id3),build_id5),build_id7),build_id9)|table svc_name,z
|mvexpand z|rex field=z "(?&amp;lt;Latestbuild&amp;gt;\w+),(?&amp;lt;Latestbuild_1&amp;gt;\w+),(?&amp;lt;Latestbuild_2&amp;gt;\w+),(?&amp;lt;Latestbuild_3&amp;gt;\w+),(?&amp;lt;Latestbuild_4&amp;gt;\w+)"|fields - z
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6764i7D640FB3BE5A6DEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Mar 2019 12:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454930#M128706</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-03-23T12:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Converting unique IDs into chart column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454931#M128707</link>
      <description>&lt;P&gt;Renjith, thanks very much for such a supremely detailed answer. I came across streamstats on Friday evening and thought that would present a way forward - you've really helped me accelerate towards achieving what I need to!  I do also think the events we are generating and the data we are indexing could do with some revision, which would make life easier...  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 08:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454931#M128707</guid>
      <dc:creator>jimmymccauley</dc:creator>
      <dc:date>2019-03-25T08:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting unique IDs into chart column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454932#M128708</link>
      <description>&lt;P&gt;Sorry, I am also limited in the Karma I can give at the moment! I'll pay it forward as I progress&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 08:54:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454932#M128708</guid>
      <dc:creator>jimmymccauley</dc:creator>
      <dc:date>2019-03-25T08:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Converting unique IDs into chart column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454933#M128709</link>
      <description>&lt;P&gt;Hi Jimmy (@jimmymccauley), glad that it worked!. Its alright about Karma :-). If you want to give points in a post , you can upvote the answers and comments&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 09:21:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-unique-IDs-into-chart-column-names/m-p/454933#M128709</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-03-25T09:21:30Z</dc:date>
    </item>
  </channel>
</rss>

