jumpserver/apps/terminal/mixin.py

16 lines
420 B
Python
Raw Normal View History

2024-05-07 11:33:12 +00:00
from terminal.utils.loki_client import get_loki_client
__all__ = ['LokiMixin', ]
class LokiMixin:
def get_loki_client(self):
return get_loki_client()
def create_loki_query(self, components, search):
stream_selector = '{component!=""}'
if components:
stream_selector = '{component=~"%s"}' % components
query = f'{stream_selector} |="{search}"'
return query