Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inputs.statsd] Splitting '|', unable to parse metric #7795

Closed
sahilpaudel-pe opened this issue Jul 7, 2020 · 5 comments
Closed

[inputs.statsd] Splitting '|', unable to parse metric #7795

sahilpaudel-pe opened this issue Jul 7, 2020 · 5 comments

Comments

@sahilpaudel-pe
Copy link

Telegraf.conf

[[inputs.statsd]]
protocol = "tcp"
max_tcp_connections = 250
tcp_keep_alive = false
service_address = ":8125"

[[inputs.statsd]]
protocol = "udp"
max_tcp_connections = 250
tcp_keep_alive = false
service_address = ":8125"

[[inputs.socket_listener]]
data_format = "influx"

Error message

[inputs.statsd] Splitting '|', unable to parse metric: http.request.200.count:1|c|@1.0|#method:GET,handler:statuscontroller_status,env:dev,service:carbon

I am sending the metric from elixir application.

@montanaflynn
Copy link

Related to issue #4495, the problem is the tag contains :, if you figure out how to fix this please let me know!

@JeffAshton
Copy link
Contributor

Just learned that you have to set

datadog_extensions = true

In order to parse the tags.

@iamatsundere
Copy link

Did anyone solve that, I am facing this issue too

@sahilpaudel-pe
Copy link
Author

I have formatted as below to make it work

def format_tags(tags) when is_list(tags) do
    tags
    |> Enum.join(",")
  end

  def generate_http_tags(conn) do
    controller = conn.private[:phoenix_controller] 
                  |> Atom.to_string
                  |> String.split(".") 
                  |> List.last 
                  |> String.downcase

    action =  conn.private[:phoenix_action] 
              |> Atom.to_string
              |> String.replace(":","")

    tag1 = "method=#{conn.method}"
    tag2 = "handler=#{controller}_#{action}"
    tag3 = "env=#{Application.get_env(:my_app, :env_vars)[:mix_env]}"
    tag4 = "service=my_app"

    [tag1, tag2, tag3, tag4]
  end

  def concat_prefix_tags(tags, prefix) do
    prefix <> ","
      |> Kernel.<>(tags)
  end

  def send_http_metrics(conn, prefix, "increment", value) do
    conn
      |> generate_http_tags
      |> format_tags
      |> concat_prefix_tags(prefix)
      |> StatsD.send_increment(value)
  end

@powersj
Copy link
Contributor

powersj commented Jan 18, 2022

As @JeffAshton pointed out, it appears that these stats examples are using DataDog's datagram format:

<METRIC_NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2>

Therefore, your Telegraf config will need to include the datadog_extensions = true option.

If someone has an example input value that is still seeing issues even with this configuraiton value enabled, please do feel free to include that here, along with your Telegraf configuration so that we are able to reproduce the issue. As such, I am going to close this.

@powersj powersj closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants