<?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 How to create Analytics Metrics using API in Share a Tip</title>
    <link>https://community.splunk.com/t5/Share-a-Tip/How-to-create-Analytics-Metrics-using-API/m-p/722384#M46</link>
    <description>&lt;P&gt;Creating large amounts of Analytics Metrics takes some time, and there is no official API to support this function currently.&lt;/P&gt;

&lt;P&gt;If you wish to automate this in the interim , to reduce the time taken to create them you can do the following.&lt;/P&gt;

&lt;P&gt;You would run the Authentication URL to get the JSESSIONID &amp;amp; X-CSRF-TOKEN values by running the following command&lt;/P&gt;
&lt;P&gt;curl -i --user @sername@account:password &lt;A href="https://&amp;lt;controller" target="_blank" rel="noopener nofollow noreferrer"&gt;https://&amp;lt;controller&lt;/A&gt;&amp;nbsp;url&amp;gt;/controller/auth?action=login&lt;/P&gt;

&lt;P&gt;Then using the following URL, you can create the Metric&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://&amp;lt;controller" target="_blank" rel="noopener nofollow noreferrer"&gt;https://&amp;lt;controller&lt;/A&gt;&amp;nbsp;url&amp;gt;/controller/restui/analyticsMetric/create&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Set the Header values with the responses from the Auth Query(I used Postman for this example)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="APpD_HEADERS.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/36457i35B228EB136C1F22/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Provide the Metric query you wish to create, example below&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;{"adqlQueryString":"SELECT avg(responseTime) FROM transactions WHERE application = \"TEST\"","eventType":"BIZ_TXN","enabled":true,"queryType":"ADQL_QUERY","queryName":"TEST"}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;You should then get a status 204 if it was successful.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Depending on how complex your queries are it might fail as certain strings need to be escaped. What I would suggest initially is to manually create the queries, and use developer options in your browser to view the API call being made to ensure you provide the queries in the correct format and then automate it.&lt;/DIV&gt;</description>
    <pubDate>Mon, 22 Mar 2021 08:15:39 GMT</pubDate>
    <dc:creator>Morelz</dc:creator>
    <dc:date>2021-03-22T08:15:39Z</dc:date>
    <item>
      <title>How to create Analytics Metrics using API</title>
      <link>https://community.splunk.com/t5/Share-a-Tip/How-to-create-Analytics-Metrics-using-API/m-p/722384#M46</link>
      <description>&lt;P&gt;Creating large amounts of Analytics Metrics takes some time, and there is no official API to support this function currently.&lt;/P&gt;

&lt;P&gt;If you wish to automate this in the interim , to reduce the time taken to create them you can do the following.&lt;/P&gt;

&lt;P&gt;You would run the Authentication URL to get the JSESSIONID &amp;amp; X-CSRF-TOKEN values by running the following command&lt;/P&gt;
&lt;P&gt;curl -i --user @sername@account:password &lt;A href="https://&amp;lt;controller" target="_blank" rel="noopener nofollow noreferrer"&gt;https://&amp;lt;controller&lt;/A&gt;&amp;nbsp;url&amp;gt;/controller/auth?action=login&lt;/P&gt;

&lt;P&gt;Then using the following URL, you can create the Metric&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://&amp;lt;controller" target="_blank" rel="noopener nofollow noreferrer"&gt;https://&amp;lt;controller&lt;/A&gt;&amp;nbsp;url&amp;gt;/controller/restui/analyticsMetric/create&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Set the Header values with the responses from the Auth Query(I used Postman for this example)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="APpD_HEADERS.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/36457i35B228EB136C1F22/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Provide the Metric query you wish to create, example below&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;{"adqlQueryString":"SELECT avg(responseTime) FROM transactions WHERE application = \"TEST\"","eventType":"BIZ_TXN","enabled":true,"queryType":"ADQL_QUERY","queryName":"TEST"}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;You should then get a status 204 if it was successful.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Depending on how complex your queries are it might fail as certain strings need to be escaped. What I would suggest initially is to manually create the queries, and use developer options in your browser to view the API call being made to ensure you provide the queries in the correct format and then automate it.&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Mar 2021 08:15:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Share-a-Tip/How-to-create-Analytics-Metrics-using-API/m-p/722384#M46</guid>
      <dc:creator>Morelz</dc:creator>
      <dc:date>2021-03-22T08:15:39Z</dc:date>
    </item>
  </channel>
</rss>

