Skip to content

Commit

Permalink
Merge pull request #223
Browse files Browse the repository at this point in the history
fix: add send to loki task
  • Loading branch information
lihuacai168 authored Jul 19, 2024
2 parents 5327723 + b16be88 commit 706864e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions system/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json

from celery import shared_task
from requests.auth import HTTPBasicAuth

import requests


@shared_task
def send_log_to_loki(*args, **kwargs):
url = kwargs['loki_url']
loki_username = kwargs['loki_username']
loki_password = kwargs['loki_password']
auth = HTTPBasicAuth(username=loki_username, password=loki_password)
data = kwargs['data']
headers = {
'Content-Type': 'application/json'
}
requests.post(url, headers=headers, data=json.dumps(data), auth=auth)

0 comments on commit 706864e

Please sign in to comment.