inCaller / prometheus_bot

Telegram bot for prometheus alerting
MIT License
397 stars 183 forks source link

getting error while trying parce big json #34

Open eskornev opened 6 years ago

eskornev commented 6 years ago

Hello! I'm using bot in docker, and there is problem with big alerting message, in telegram chat we getting "Error sending message, checkout logs". In docker logs there are errors "Error sending message: Bad Request: can't parse entities: Unexpected end tag at byte offset 0", with different digits at the end. JSON data is here: https://pastebin.com/31uZTPZa

hryamzik commented 6 years ago

Can you reproduce this using tests?

eskornev commented 6 years ago

yes, using docker on local machine: curl -H "Content-Type: application/json" -d '' http://localhost:9087/alert/

result is error: {"err":"Bad Request: can't parse entities: Unclosed start tag at byte offset 3890","message":{"message_id":0,"from":null,"date":0,"chat":null,"forward_from":null,"forward_from_chat":null,"forward_from_message_id":0,"forward_date":0,"reply_to_message":null,"edit_date":0,"text":"","entities":null,"audio":null,"document":null,"game":null,"photo":null,"sticker":null,"video":null,"video_note":null,"voice":null,"caption":"","contact":null,"location":null,"venue":null,"new_chat_members":null,"left_chat_member":null,"new_chat_title":"","new_chat_photo":null,"delete_chat_photo":false,"group_chat_created":false,"supergroup_chat_created":false,"channel_chat_created":false,"migrate_to_chat_id":0,"migrate_from_chat_id":0,"pinned_message":null,"invoice":null,"successful_payment":null},"srcmsg":"\n\u003cb\u003eLabels:\u003c/b\u003e\n alertname = \u003ccode\u003eKube_zone1_container_is_not_running\u003c/code\u003e\n container =...

ainmosni commented 6 years ago

Yeah I'm getting these as well, makes it spam telegram.

pvlltvk commented 6 years ago

Getting same error, as i can understand the error arise when bot try to split big json to multiple messages, and as a result message have invalid html format (without end tag).

hryamzik commented 6 years ago

PRs are welcomed.

favadi commented 6 years ago

Splitting HTML document is not easy. As an workaround we could add this to the config.yaml file to avoid splitting. Notice that Telegram might refuse to send if the message is too big.

split_msg_byte: 2147483647 # math.MaxInt32
yctn commented 5 years ago

im having the same issue. any news on this?