<?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 Logs to Metric Custom Format in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Logs-to-Metric-Custom-Format/m-p/741162#M117837</link>
    <description>&lt;P&gt;I am having difficulty converting event logs to metric data points&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.0/Metrics/L2MOverview" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.0/Metrics/L2MOverview&lt;/A&gt;&amp;nbsp;According to the documentation, I think I need index-time extraction to modify the fields in the event as such:&lt;/P&gt;&lt;P&gt;raw event examples&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;server_request_bytes{kafka_id="lkc-j2km8w",principal_id="u-j69zjw",type="Fetch",} 3.14 1736873280000

server_response_bytes{kafka_id="lkc-j2km8w",principal_id="u-j69zjw",type="ApiVersions",} 4.2 1736873280000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My &lt;STRONG&gt;Goal is to parse so that the event has the fields necessary for log to metric conversion&lt;/STRONG&gt;. I think that means these are required (in addition to timestamp):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;metric_name:server_request_byes
numeric_value: 3.14
measurement:server_request_byes=3.14&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 stanzas in transforms.conf which parse the metric name, and the numeric value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[metric_name]
REGEX = ^"(?P&amp;lt;metric_name&amp;gt;[a-z_-]+_[a-z_-]+\w+)
FORMAT = metric_name::$metric_name

[numeric_value]
REGEX = ^[^ \n]* (?P&amp;lt;metric_value&amp;gt;\d+\.\d+)
FORMAT = numeric_value::$metric_value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(props.conf looks like this:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[my_log_to_metrics]
# extract metric fields
TRANSFORMS-metric_name = metric_name
TRANSFORMS-numeric_value = numeric_value
category = Log to Metrics
# parse timestamp
TIME_PREFIX = \}\s.*\s
TIME_FORMAT = %s%3N
MAX_TIMESTAMP_LOOKAHEAD = 20
NO_BINARY_CHECK = true
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, when I try using this sourcetype I see this error message in splunkd log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Metric event data without a metric name and properly formated numerical values are invalid and cannot be indexed. Ensure the input metric data is not malformed, have one or more keys of the form "metric_name:&amp;lt;metric&amp;gt;" (e.g..."metric_name:cpu.idle") with corresponding floating point values.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(And no metric data in the metrics index)&lt;/P&gt;&lt;P&gt;I have a couple of questions:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Are the fields metric_name, numeric_value, and measurement required to be extracted at index time with transforms.conf for the log to metric conversion?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. How can I combine the extracted name and value fields to create the measurement field without writing another regex statement to parse the same thing?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. How can I parse all of the fields between the curly braces (kafka_id, principal_id, type) as dimensions for the metric, in a generic way?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Mar 2025 18:27:00 GMT</pubDate>
    <dc:creator>rrossetti</dc:creator>
    <dc:date>2025-03-07T18:27:00Z</dc:date>
    <item>
      <title>Logs to Metric Custom Format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Logs-to-Metric-Custom-Format/m-p/741162#M117837</link>
      <description>&lt;P&gt;I am having difficulty converting event logs to metric data points&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.0/Metrics/L2MOverview" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.0/Metrics/L2MOverview&lt;/A&gt;&amp;nbsp;According to the documentation, I think I need index-time extraction to modify the fields in the event as such:&lt;/P&gt;&lt;P&gt;raw event examples&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;server_request_bytes{kafka_id="lkc-j2km8w",principal_id="u-j69zjw",type="Fetch",} 3.14 1736873280000

server_response_bytes{kafka_id="lkc-j2km8w",principal_id="u-j69zjw",type="ApiVersions",} 4.2 1736873280000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My &lt;STRONG&gt;Goal is to parse so that the event has the fields necessary for log to metric conversion&lt;/STRONG&gt;. I think that means these are required (in addition to timestamp):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;metric_name:server_request_byes
numeric_value: 3.14
measurement:server_request_byes=3.14&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 stanzas in transforms.conf which parse the metric name, and the numeric value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[metric_name]
REGEX = ^"(?P&amp;lt;metric_name&amp;gt;[a-z_-]+_[a-z_-]+\w+)
FORMAT = metric_name::$metric_name

[numeric_value]
REGEX = ^[^ \n]* (?P&amp;lt;metric_value&amp;gt;\d+\.\d+)
FORMAT = numeric_value::$metric_value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(props.conf looks like this:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[my_log_to_metrics]
# extract metric fields
TRANSFORMS-metric_name = metric_name
TRANSFORMS-numeric_value = numeric_value
category = Log to Metrics
# parse timestamp
TIME_PREFIX = \}\s.*\s
TIME_FORMAT = %s%3N
MAX_TIMESTAMP_LOOKAHEAD = 20
NO_BINARY_CHECK = true
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, when I try using this sourcetype I see this error message in splunkd log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Metric event data without a metric name and properly formated numerical values are invalid and cannot be indexed. Ensure the input metric data is not malformed, have one or more keys of the form "metric_name:&amp;lt;metric&amp;gt;" (e.g..."metric_name:cpu.idle") with corresponding floating point values.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(And no metric data in the metrics index)&lt;/P&gt;&lt;P&gt;I have a couple of questions:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Are the fields metric_name, numeric_value, and measurement required to be extracted at index time with transforms.conf for the log to metric conversion?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. How can I combine the extracted name and value fields to create the measurement field without writing another regex statement to parse the same thing?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. How can I parse all of the fields between the curly braces (kafka_id, principal_id, type) as dimensions for the metric, in a generic way?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 18:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Logs-to-Metric-Custom-Format/m-p/741162#M117837</guid>
      <dc:creator>rrossetti</dc:creator>
      <dc:date>2025-03-07T18:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Logs to Metric Custom Format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Logs-to-Metric-Custom-Format/m-p/741164#M117838</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255562"&gt;@rrossetti&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try without a named capture group and use $1 instead.&amp;nbsp;&lt;BR /&gt;The docs say:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Use $n (for example $1, $2, etc) to specify the output of each REGEX&lt;/LI-CODE&gt;&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.1/Admin/Transformsconf" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.1/Admin/Transformsconf&lt;/A&gt; for more info.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Will&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 18:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Logs-to-Metric-Custom-Format/m-p/741164#M117838</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-03-07T18:41:00Z</dc:date>
    </item>
  </channel>
</rss>

