holmesgpt 0.11.5__py3-none-any.whl → 0.12.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of holmesgpt might be problematic. Click here for more details.

Files changed (41) hide show
  1. holmes/__init__.py +1 -1
  2. holmes/common/env_vars.py +8 -4
  3. holmes/config.py +54 -14
  4. holmes/core/investigation_structured_output.py +7 -0
  5. holmes/core/llm.py +14 -4
  6. holmes/core/models.py +24 -0
  7. holmes/core/tool_calling_llm.py +48 -6
  8. holmes/core/tools.py +7 -4
  9. holmes/core/toolset_manager.py +24 -5
  10. holmes/core/tracing.py +224 -0
  11. holmes/interactive.py +761 -44
  12. holmes/main.py +59 -127
  13. holmes/plugins/prompts/_fetch_logs.jinja2 +4 -0
  14. holmes/plugins/prompts/kubernetes_workload_ask.jinja2 +2 -10
  15. holmes/plugins/toolsets/__init__.py +10 -2
  16. holmes/plugins/toolsets/azure_sql/apis/azure_sql_api.py +2 -1
  17. holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py +3 -0
  18. holmes/plugins/toolsets/datadog/datadog_api.py +161 -0
  19. holmes/plugins/toolsets/datadog/datadog_metrics_instructions.jinja2 +26 -0
  20. holmes/plugins/toolsets/datadog/datadog_traces_formatter.py +310 -0
  21. holmes/plugins/toolsets/datadog/instructions_datadog_traces.jinja2 +51 -0
  22. holmes/plugins/toolsets/datadog/toolset_datadog_logs.py +267 -0
  23. holmes/plugins/toolsets/datadog/toolset_datadog_metrics.py +488 -0
  24. holmes/plugins/toolsets/datadog/toolset_datadog_traces.py +689 -0
  25. holmes/plugins/toolsets/grafana/toolset_grafana_loki.py +3 -0
  26. holmes/plugins/toolsets/internet/internet.py +1 -1
  27. holmes/plugins/toolsets/logging_utils/logging_api.py +9 -3
  28. holmes/plugins/toolsets/opensearch/opensearch_logs.py +3 -0
  29. holmes/plugins/toolsets/utils.py +6 -2
  30. holmes/utils/cache.py +4 -4
  31. holmes/utils/console/consts.py +2 -0
  32. holmes/utils/console/logging.py +95 -0
  33. holmes/utils/console/result.py +37 -0
  34. holmes/utils/robusta.py +2 -3
  35. {holmesgpt-0.11.5.dist-info → holmesgpt-0.12.0a0.dist-info}/METADATA +3 -4
  36. {holmesgpt-0.11.5.dist-info → holmesgpt-0.12.0a0.dist-info}/RECORD +39 -30
  37. {holmesgpt-0.11.5.dist-info → holmesgpt-0.12.0a0.dist-info}/WHEEL +1 -1
  38. holmes/__init__.py.bak +0 -76
  39. holmes/plugins/toolsets/datadog.py +0 -153
  40. {holmesgpt-0.11.5.dist-info → holmesgpt-0.12.0a0.dist-info}/LICENSE.txt +0 -0
  41. {holmesgpt-0.11.5.dist-info → holmesgpt-0.12.0a0.dist-info}/entry_points.txt +0 -0
@@ -1,153 +0,0 @@
1
- import requests # type: ignore
2
- import logging
3
- from typing import Any, Optional, Dict, Tuple
4
- from holmes.core.tools import (
5
- CallablePrerequisite,
6
- Tool,
7
- ToolParameter,
8
- Toolset,
9
- ToolsetTag,
10
- )
11
- from pydantic import BaseModel
12
- from holmes.core.tools import StructuredToolResult, ToolResultStatus
13
-
14
-
15
- class BaseDatadogTool(Tool):
16
- toolset: "DatadogToolset"
17
-
18
-
19
- class GetLogs(BaseDatadogTool):
20
- def __init__(self, toolset: "DatadogToolset"):
21
- super().__init__(
22
- name="datadog_get_logs",
23
- description="Retrieve logs from Datadog",
24
- parameters={
25
- "service": ToolParameter(
26
- description="The service name to filter logs",
27
- type="string",
28
- required=True,
29
- ),
30
- "from_time": ToolParameter(
31
- description="Start time for logs (e.g., '2025-02-23T08:00:00Z')",
32
- type="string",
33
- required=True,
34
- ),
35
- "to_time": ToolParameter(
36
- description="End time for logs (e.g., '2025-02-23T11:00:00Z')",
37
- type="string",
38
- required=True,
39
- ),
40
- },
41
- toolset=toolset,
42
- )
43
-
44
- def _invoke(self, params: Any) -> StructuredToolResult:
45
- def success(msg: Any) -> StructuredToolResult:
46
- return StructuredToolResult(
47
- status=ToolResultStatus.SUCCESS,
48
- data=msg,
49
- params=params,
50
- )
51
-
52
- def error(msg: str) -> StructuredToolResult:
53
- return StructuredToolResult(
54
- status=ToolResultStatus.ERROR,
55
- data=msg,
56
- params=params,
57
- )
58
-
59
- service = params.get("service")
60
- from_time = params.get("from_time")
61
- to_time = params.get("to_time")
62
-
63
- url = "https://api.us5.datadoghq.com/api/v2/logs/events/search"
64
- headers = {
65
- "Content-Type": "application/json",
66
- "DD-API-KEY": self.toolset.dd_api_key,
67
- "DD-APPLICATION-KEY": self.toolset.dd_app_key,
68
- }
69
-
70
- payload = {
71
- "filter": {
72
- "from": from_time,
73
- "to": to_time,
74
- "query": f"service:{service}",
75
- },
76
- "sort": "timestamp",
77
- "page": {"limit": 1000},
78
- }
79
-
80
- try:
81
- logging.info(
82
- f"Fetching Datadog logs for service '{service}' from {from_time} to {to_time}"
83
- )
84
- response = requests.post(url, headers=headers, json=payload)
85
-
86
- if response.status_code == 200:
87
- data = response.json()
88
- logs = [
89
- log["attributes"].get("message", "[No message]")
90
- for log in data.get("data", [])
91
- ]
92
- if logs:
93
- return success("\n".join(logs))
94
- else:
95
- logging.warning(f"No logs found for service {service}")
96
- return success("[No logs found]")
97
-
98
- logging.warning(
99
- f"Failed to fetch logs. Status code: {response.status_code}, Response: {response.text}"
100
- )
101
- return error(
102
- f"Failed to fetch logs. Status code: {response.status_code}\n{response.text}"
103
- )
104
-
105
- except Exception as e:
106
- logging.exception(f"Failed to query Datadog logs for params: {params}")
107
- return error(f"Exception while querying Datadog: {str(e)}")
108
-
109
- def get_parameterized_one_liner(self, params) -> str:
110
- return f"datadog GetLogs(service='{params.get('service')}', from_time='{params.get('from_time')}', to_time='{params.get('to_time')}')"
111
-
112
-
113
- class DatadogConfig(BaseModel):
114
- dd_api_key: str
115
- dd_app_key: str
116
-
117
-
118
- class DatadogToolset(Toolset):
119
- dd_api_key: Optional[str] = None
120
- dd_app_key: Optional[str] = None
121
-
122
- def __init__(self):
123
- super().__init__(
124
- name="datadog",
125
- description="Toolset for interacting with Datadog to fetch logs",
126
- docs_url="https://docs.datadoghq.com/api/latest/logs/",
127
- icon_url="https://imgix.datadoghq.com//img/about/presskit/DDlogo.jpg",
128
- prerequisites=[CallablePrerequisite(callable=self.prerequisites_callable)],
129
- tools=[
130
- GetLogs(self),
131
- ],
132
- experimental=True,
133
- tags=[ToolsetTag.CORE],
134
- )
135
-
136
- def prerequisites_callable(self, config: dict[str, Any]) -> Tuple[bool, str]:
137
- if not config:
138
- return (
139
- False,
140
- "Datadog toolset is misconfigured. 'dd_api_key' and 'dd_app_key' are required.",
141
- )
142
-
143
- try:
144
- dd_config = DatadogConfig(**config)
145
- self.dd_api_key = dd_config.dd_api_key
146
- self.dd_app_key = dd_config.dd_app_key
147
- return True, ""
148
- except Exception as e:
149
- logging.exception("Failed to set up Datadog toolset")
150
- return (False, f"Failed to parse Datadog configuration: {str(e)}")
151
-
152
- def get_example_config(self) -> Dict[str, Any]:
153
- return {}