grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
65.07k stars 12.15k forks source link

Grafana Live: Unable to push strings with certain valid Unicode characters #67818

Open Sh4pe opened 1 year ago

Sh4pe commented 1 year ago

What went wrong?

What happened:

I'm pushing metrics to Grafana Live over WebSockets. These metrics contain strings. When the strings contain a form feed (U+000C) or carriage return (U+000D), the metrics are rejected. In the Grafana logs, I even see that the line protocol telegram appears to be truncated after the carriage return - the timestamp is left off, see my examples below.

Error log in case of form feed:

ERROR[05-04|10:05:02] Error converting metrics                 logger=live.push_ws error="error converting metrics: error parsing metrics: metric parse error: expected field at 1:17: \"something test=\\\"\\f\\\" 1681164826166000000\"" frameFormat=labels_column

Error log in case of carriage return:

ERROR[05-04|10:05:08] Error converting metrics                 logger=live.push_ws error="error converting metrics: error parsing metrics: metric parse error: expected field at 1:18: \"something test=\\\"\"" frameFormat=labels_column

I've tested this against both v9.1.5 and v9.5.1 (bc353e4b2d).

What did you expect to happen:

I expect that Grafana Live can consume any metric containing valid UTF-8 strings. In case that is not possible, I expect the strict subset of UTF-8 that is supported by Grafana Live to be documented somewhere.

How do we reproduce it?

Step 1:

Establish WebSocket connection to Grafana Live instance.

Step 2:

Send either of these line protocol messages (generated with Python code):

websocket_messages = [
    f'something_metric some_string="{chr(12)}" 1681164826166000000',
    f'something_metric some_string="{chr(13)}" 1681164826166000000'
]

Step 3:

See the error logs for the rejection message.

What Grafana version are you using?

v9.1.5, v9.5.1 (bc353e4b2d)

Optional Questions:

Is the bug inside a Dashboard Panel?

Copy the panel's "get-help" data here

Grafana Platform?

None

User's OS?

No response

User's Browser?

No response

Is this a Regression?

None

Are Datasources involved?

No response

Anything else to add?

No response

Sh4pe commented 1 year ago

This might be related to #43765.

github-actions[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!