prometheus_exporter icon indicating copy to clipboard operation
prometheus_exporter copied to clipboard

PrometheusExporter::Server::Collector#process JSON::ParserError

Open konfortes opened this issue 3 years ago • 13 comments

Hey, I have a ruby app, sending metrics to the built-in collector through the client. For some reason, I'm getting 500 response to POST /send-metrics with log messages like: #<JSON::ParserError: 767: unexpected token at (full message below) with this trace:

server /usr/local/lib/ruby/2.6.0/json/common.rb:156:in `parse'
server /usr/local/lib/ruby/2.6.0/json/common.rb:156:in `parse'
server /usr/local/bundle/gems/prometheus_exporter-0.5.1/lib/prometheus_exporter/server/collector.rb:29:in `process'
server /usr/local/bundle/gems/prometheus_exporter-0.5.1/lib/prometheus_exporter/server/web_server.rb:82:in `block in handle_metrics'
server /usr/local/lib/ruby/2.6.0/webrick/httprequest.rb:546:in `read_chunked'
server /usr/local/lib/ruby/2.6.0/webrick/httprequest.rb:506:in `read_body'
server /usr/local/lib/ruby/2.6.0/webrick/httprequest.rb:256:in `body'
server /usr/local/bundle/gems/prometheus_exporter-0.5.1/lib/prometheus_exporter/server/web_server.rb:79:in `handle_metrics'
server /usr/local/bundle/gems/prometheus_exporter-0.5.1/lib/prometheus_exporter/server/web_server.rb:69:in `block in initialize'
server /usr/local/lib/ruby/2.6.0/webrick/httpservlet/prochandler.rb:39:in `do_GET'
server /usr/local/lib/ruby/2.6.0/webrick/httpservlet/abstract.rb:105:in `service'
server /usr/local/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
server /usr/local/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
server /usr/local/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

My usage is pretty basic, kind of copy-paste from the readme:

collector:

CMD ["bundle", "exec", "prometheus_exporter", "-b", "0.0.0.0", "-t", "3", "--prefix", "my_app_"]

client:

PrometheusExporter::Client.default = PrometheusExporter::Client.new(custom_labels: {app: 'workers', env: 'production'})
Prometheus::Client.register_counter('order_links', 'order links')

Prometheus::Client.increment('order_links', link:: 'billing_phone')

Full Message:

server #<JSON::ParserError: 767: unexpected token at '{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"customer_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"shipping_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"customer_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"shipping_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"shipping_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"shipping_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_address1"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"wp_billing_formatted_address"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_first_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_last_name"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}{"type":"counter","help":"order links","name":"order_links","keys":{"link":"billing_phone"},"value":1,"prometheus_exporter_action":"increment","custom_labels":{"app":"workers","env":"production"}}'>

I guess this is a WEBrick log, right? should it be a valid json? (there are no commas between items)

konfortes avatar Jul 07 '20 15:07 konfortes