We have Grafana server installed and along side grafana we have also configured the, Loki as docker container service.
I trying to send logs from lambda to loki on its endpoint: /loki/api/v1/push. The Lambda is returning Status Code 400.
Here is sample of my Payload, which is being send:
{"streams": [{"stream": {"job": "loki_testing", "source": "loki"}, "values": [["1704364172000", "test"]]}]}
Few times Jobs and Source are visible, in grafana, but it returns:
Update
I am push log using CURL, while same logs is not being pushed using Lambda.
While I am checking the logs which was pushed from CURL Commands in grafana it returns:
If anyone has any idea regarding both of above issue mentioned, Please let me know. Any help will be appreciated.
stack-overflow community, I have resolved the above issue. The issue was related to Epoch Time, which I used to send to the Loki gateway. I was not accepted at Loki.
Here is code, I have used to rectify the epoch time:
DATE_STRING = LOG_STRING['createdDate'] #Used to fetch from logs.
print(DATE_STRING)
DT = datetime.datetime.strptime(DATE_STRING, '%Y-%m-%dT%H:%M:%S.%fZ') #Converting the date to required format.
FORMATTED_DT = DT.strftime('%Y-%m-%d %H:%M:%S') # Converting it in string format.
EPOCH_TIME = str(int(time.time())) # Fetching current, as the Date string is from different time as compared to current time, It will be send as value in loki, not as timestamp.
EPOCH_TIME = EPOCH_TIME + "000000000" # Converting it into required format, by adding few zero.
Note: Add in log string you want to send and it will be to go, if there is no issue in log line.