You can download this code by clicking the button below.
This code is now available for download.
This function sends a query through the Graylog client and returns the stream name of the first message that matches the query. If the query does not match any messages, it returns None.
Technology Stack : graylog
Code Type : Function
Code Difficulty : Intermediate
def graylog_query_stream_name(graylog_client, query):
"""
Query the Graylog API to get the stream name based on the given query.
"""
response = graylog_client.search(query)
for message in response.messages:
return message['message']['fields'].get('stream')
return None