84 lines
2.1 KiB
Markdown
84 lines
2.1 KiB
Markdown
# osnova-api-alert
|
|
|
|
swagger - https://osnova-api-alert.sm8255082.ru/docs
|
|
|
|
endpoints:
|
|
- https://osnova-api-alert.sm8255082.ru/ping (get, post)
|
|
без авторизации, без параметров
|
|
- https://osnova-api-alert.sm8255082.ru/api/v1/zbx/send-to-dashboard (post)
|
|
в заголовке должен быть токен 'x-api-key: токен'
|
|
должны предаваться в data:
|
|
|
|
```json
|
|
{
|
|
"text": "string",
|
|
"subject": "string",
|
|
"problem_id": 0
|
|
}
|
|
```
|
|
- https://osnova-api-alert.sm8255082.ru/api/v1/zbx/send-to-net-chat (post)
|
|
в заголовке должен быть токен 'x-api-key: токен'
|
|
должны предаваться в data:
|
|
|
|
```json
|
|
{
|
|
"text": "string",
|
|
"subject": "string"
|
|
}
|
|
```
|
|
|
|
|
|
|
|
js для заббикса:
|
|
|
|
```javascript
|
|
function sendMessage(value) {
|
|
var params = JSON.parse(value),
|
|
data,
|
|
response,
|
|
request = new HttpRequest(),
|
|
url = 'https://osnova-api-alert.sm8255082.ru/api/v1/tg/send';
|
|
request.addHeader('Content-Type: application/json');
|
|
request.addHeader('x-api-key: токен');
|
|
data = JSON.stringify(params);
|
|
response = request.post(url, data);
|
|
|
|
if (request.getStatus() === 200) {
|
|
return 'OK';
|
|
}
|
|
else {
|
|
if (typeof response.description === 'string') {
|
|
throw response.description;
|
|
}
|
|
else {
|
|
throw 'Unknown error. Check debug log for more information.';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
Zabbix.log(4, value)
|
|
sendMessage(value);
|
|
return 'OK';
|
|
}
|
|
catch (error) {
|
|
throw 'Unknown error ' + error;
|
|
}
|
|
```
|
|
|
|
|
|
You can try to get the message_thread_id from the message link
|
|
|
|
- send a message to the topic you need from the application
|
|
- right click on the sent message and choose "Copy message link"
|
|
- paste link somewhere
|
|
- you will see something like this: https://t.me/c/1112223334/25/33
|
|
- the value 25(value after long number) from the link will be message_thread_id
|
|
|
|
I assume that -100 + 1112223334 - will be equal chat_id
|
|
|
|
The number after will be message_thread_id
|
|
|
|
And the last one should be message_id
|