msticpy.data.drivers.sumologic_driver module
Sumologic Driver class.
- class msticpy.data.drivers.sumologic_driver.SumologicDriver(**kwargs)
Bases:
DriverBase
Driver to connect and query from Sumologic.
Instantiate Sumologic Driver.
- add_query_filter(name: str, query_filter: str | Iterable)
Add an expression to the query attach filter.
- connect(connection_str: str | None = None, **kwargs)
Connect to Sumologic via sumologic-sdk.
- Parameters:
connection_str – Sumologic API url endpoint. default: https://api.us2.sumologic.com/api
kwargs – Connection parameters can be supplied as keyword parameters.
Notes
Default configuration is read from the DataProviders/Sumologic section of msticpyconfig.yaml, if available.
- property connected: bool
Return true if at least one connection has been made.
- Returns:
True if a successful connection has been made.
- Return type:
bool
Notes
This does not guarantee that the last data source connection was successful. It is a best effort to track whether the provider has made at least one successful authentication.
- property driver_queries: Iterable[Dict[str, Any]]
Return queries retrieved from the service after connecting.
- Returns:
List of Dictionary of query_name, query_text. Name of container to add queries to.
- Return type:
List[Dict[str, str]]
- get_driver_property(name: str) Any
Return value or KeyError from driver properties.
- static get_http_timeout(**kwargs)
Get http timeout from settings or kwargs.
- property instance: str | None
Return instance name, if one is set.
- Returns:
The name of driver instance or None if the driver does not support multiple instances
- Return type:
Optional[str]
- property loaded: bool
Return true if the provider is loaded.
- Returns:
True if the provider is loaded.
- Return type:
bool
Notes
This is not relevant for some providers.
- query(query: str, query_source: QuerySource | None = None, **kwargs) DataFrame | Any
Execute Sumologic query and retrieve results.
- Parameters:
query (str) – Sumologic query to execute
query_source (QuerySource) – Not used.
days (int) – Search the past X days.
start (datetime) – A datetime() object representing the start of the search window. If used without end_time, the end of the search window is the current time.
start_time (datetime) – alias for start
end (datetime) – A datetime() object representing the end of the search window. If used without start_time, the search start will be the earliest time in the index.
end_time (datetime) – alias for end
timeZone (str) – timezone used for time range search
byReceiptTime (datetime) – if time reference should used _receiptTime (time when Sumologic got message) instead of _messageTime (time present in log message).
limit (int) – An integer describing the max number of search results to return.
forceMessagesResults (bool) – Force results to be raw messages even if aggregated query.
verbosity (int) – Provide more verbose state. from 0 least verbose to 4 most one.
normalize (bool) – If set to True, fields containing structures (i.e. subfields) will be flattened such that each field has it’s own column in the dataframe. If False, there will be a single column for the structure, with a JSON string encoding all the contents.
exporting (bool) – Export result to file.
export_path (str) – file path for exporte results.
time_columns (array[string]) – returning columns which format should be dataframe timestamp
numeric_columns (array[string]) – returning columns which format should be dataframe numeric
- Returns:
Query results in a dataframe. or query response if an error.
- Return type:
Union[pd.DataFrame, Any]
- property query_attach_spec: Dict[str, Set[str]]
Parameters that determine whether a query is relevant for the driver.
- query_usable(query_source: QuerySource) bool
Return True if query should be exposed for this driver.
- query_with_results(query: str, **kwargs) Tuple[DataFrame, Any]
Execute query string and return DataFrame of results.
- Parameters:
query (str) – Query to execute against Sumologic instance.
- Returns:
A DataFrame (if successful) or the underlying provider result if an error occurs.
- Return type:
Union[pd.DataFrame,Any]
- property schema: Dict[str, Dict]
Return current data schema of connection.
- Returns:
Data schema of current connection.
- Return type:
Dict[str, Dict]
- property service_queries: Tuple[Dict[str, str], str]
Return queries retrieved from the service after connecting.
- Returns:
Dictionary of query_name, query_text. Name of container to add queries to.
- Return type:
Tuple[Dict[str, str], str]
- set_driver_property(name: str, value: Any)
Set an item in driver properties.