mcp-instana 0.1.0__py3-none-any.whl → 0.1.1__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.
- mcp_instana-0.1.1.dist-info/METADATA +908 -0
- mcp_instana-0.1.1.dist-info/RECORD +30 -0
- {mcp_instana-0.1.0.dist-info → mcp_instana-0.1.1.dist-info}/WHEEL +1 -1
- mcp_instana-0.1.1.dist-info/entry_points.txt +4 -0
- mcp_instana-0.1.0.dist-info/LICENSE → mcp_instana-0.1.1.dist-info/licenses/LICENSE.md +3 -3
- src/application/__init__.py +1 -0
- src/{client/application_alert_config_mcp_tools.py → application/application_alert_config.py} +251 -273
- src/application/application_analyze.py +415 -0
- src/application/application_catalog.py +153 -0
- src/{client/application_metrics_mcp_tools.py → application/application_metrics.py} +107 -129
- src/{client/application_resources_mcp_tools.py → application/application_resources.py} +128 -150
- src/application/application_settings.py +1135 -0
- src/application/application_topology.py +107 -0
- src/core/__init__.py +1 -0
- src/core/server.py +436 -0
- src/core/utils.py +213 -0
- src/event/__init__.py +1 -0
- src/{client/events_mcp_tools.py → event/events_tools.py} +128 -136
- src/infrastructure/__init__.py +1 -0
- src/{client/infrastructure_analyze_mcp_tools.py → infrastructure/infrastructure_analyze.py} +200 -203
- src/{client/infrastructure_catalog_mcp_tools.py → infrastructure/infrastructure_catalog.py} +194 -264
- src/infrastructure/infrastructure_metrics.py +167 -0
- src/{client/infrastructure_resources_mcp_tools.py → infrastructure/infrastructure_resources.py} +192 -223
- src/{client/infrastructure_topology_mcp_tools.py → infrastructure/infrastructure_topology.py} +105 -106
- src/log/__init__.py +1 -0
- src/log/log_alert_configuration.py +331 -0
- src/prompts/mcp_prompts.py +900 -0
- src/prompts/prompt_loader.py +29 -0
- src/prompts/prompt_registry.json +21 -0
- mcp_instana-0.1.0.dist-info/METADATA +0 -649
- mcp_instana-0.1.0.dist-info/RECORD +0 -19
- mcp_instana-0.1.0.dist-info/entry_points.txt +0 -3
- src/client/What is the sum of queue depth for all q +0 -55
- src/client/instana_client_base.py +0 -93
- src/client/log_alert_configuration_mcp_tools.py +0 -316
- src/client/show the top 5 services with the highest +0 -28
- src/mcp_server.py +0 -343
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Log Alert Configuration MCP Tools Module
|
|
3
|
+
|
|
4
|
+
This module provides log alert configuration-specific MCP tools for Instana monitoring.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import sys
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from typing import Any, Dict, List, Optional
|
|
11
|
+
|
|
12
|
+
# Configure logger for this module
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
# Import the necessary classes from the SDK
|
|
16
|
+
try:
|
|
17
|
+
from instana_client.api.log_alert_configuration_api import LogAlertConfigurationApi
|
|
18
|
+
from instana_client.api_client import ApiClient
|
|
19
|
+
from instana_client.configuration import Configuration
|
|
20
|
+
from instana_client.models.log_alert_config import LogAlertConfig
|
|
21
|
+
except ImportError:
|
|
22
|
+
logger.error("Failed to import Instana client modules", exc_info=True)
|
|
23
|
+
raise
|
|
24
|
+
|
|
25
|
+
from src.core.utils import BaseInstanaClient, register_as_tool
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class LogAlertConfigurationMCPTools(BaseInstanaClient):
|
|
29
|
+
"""Tools for log alert configuration in Instana MCP."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, read_token: str, base_url: str):
|
|
32
|
+
"""Initialize the Log Alert Configuration MCP tools client."""
|
|
33
|
+
super().__init__(read_token=read_token, base_url=base_url)
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
logger.debug(f"Initializing LogAlertConfigurationMCPTools with base_url={base_url}")
|
|
37
|
+
|
|
38
|
+
# Configure the API client with the correct base URL and authentication
|
|
39
|
+
configuration = Configuration()
|
|
40
|
+
configuration.host = base_url
|
|
41
|
+
configuration.api_key['ApiKeyAuth'] = read_token
|
|
42
|
+
configuration.api_key_prefix['ApiKeyAuth'] = 'apiToken'
|
|
43
|
+
|
|
44
|
+
# Create an API client with this configuration
|
|
45
|
+
api_client = ApiClient(configuration=configuration)
|
|
46
|
+
|
|
47
|
+
# Initialize the Instana SDK's LogAlertConfigurationApi with our configured client
|
|
48
|
+
self.log_alert_api = LogAlertConfigurationApi(api_client=api_client)
|
|
49
|
+
logger.debug(f"Initialized LogAlertConfigurationApi with host: {configuration.host}")
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logger.error(f"Error initializing LogAlertConfigurationApi: {e}", exc_info=True)
|
|
52
|
+
raise
|
|
53
|
+
|
|
54
|
+
@register_as_tool
|
|
55
|
+
async def create_log_alert_config(self, config: Dict[str, Any], ctx=None) -> Dict[str, Any]:
|
|
56
|
+
"""
|
|
57
|
+
Create a new log alert configuration.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
config: Dictionary containing the log alert configuration
|
|
61
|
+
Required fields:
|
|
62
|
+
- name: Name of the alert
|
|
63
|
+
- query: Log query string
|
|
64
|
+
- threshold: Threshold value for the alert
|
|
65
|
+
- timeThreshold: Time threshold in milliseconds
|
|
66
|
+
- rule: Rule configuration
|
|
67
|
+
ctx: The MCP context (optional)
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Dictionary containing the created log alert configuration or error information
|
|
71
|
+
"""
|
|
72
|
+
try:
|
|
73
|
+
logger.debug(f"create_log_alert_config called with config={config}")
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
# Convert dictionary to LogAlertConfig model
|
|
77
|
+
log_alert_config = LogAlertConfig(**config)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
logger.error(f"Error creating LogAlertConfig: {e}", exc_info=True)
|
|
80
|
+
return {"error": f"Failed to create log alert configuration: {e!s}"}
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
# Call the API
|
|
84
|
+
result = self.log_alert_api.create_log_alert_config(log_alert_config=log_alert_config)
|
|
85
|
+
logger.debug(f"Result from create_log_alert_config: {result}")
|
|
86
|
+
return self._convert_to_dict(result)
|
|
87
|
+
except Exception as e:
|
|
88
|
+
logger.error(f"Error calling create_log_alert_config API: {e}", exc_info=True)
|
|
89
|
+
return {"error": f"Failed to create log alert configuration: {e!s}"}
|
|
90
|
+
except Exception as e:
|
|
91
|
+
logger.error(f"Error in create_log_alert_config: {e}", exc_info=True)
|
|
92
|
+
return {"error": f"Failed to create log alert configuration: {e!s}"}
|
|
93
|
+
|
|
94
|
+
@register_as_tool
|
|
95
|
+
async def delete_log_alert_config(self, id: str, ctx=None) -> Dict[str, Any]:
|
|
96
|
+
"""
|
|
97
|
+
Delete a log alert configuration.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
id: ID of the log alert configuration to delete
|
|
101
|
+
ctx: The MCP context (optional)
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Dictionary containing the result of the deletion operation or error information
|
|
105
|
+
"""
|
|
106
|
+
try:
|
|
107
|
+
logger.debug(f"delete_log_alert_config called with id={id}")
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
self.log_alert_api.delete_log_alert_config(id=id)
|
|
111
|
+
logger.debug(f"Successfully deleted log alert configuration with ID {id}")
|
|
112
|
+
return {"success": True, "message": f"Log alert configuration with ID {id} deleted successfully"}
|
|
113
|
+
except Exception as e:
|
|
114
|
+
logger.error(f"Error calling delete_log_alert_config API: {e}", exc_info=True)
|
|
115
|
+
return {"error": f"Failed to delete log alert configuration: {e!s}"}
|
|
116
|
+
except Exception as e:
|
|
117
|
+
logger.error(f"Error in delete_log_alert_config: {e}", exc_info=True)
|
|
118
|
+
return {"error": f"Failed to delete log alert configuration: {e!s}"}
|
|
119
|
+
|
|
120
|
+
@register_as_tool
|
|
121
|
+
async def disable_log_alert_config(self, id: str, ctx=None) -> Dict[str, Any]:
|
|
122
|
+
"""
|
|
123
|
+
Disable a log alert configuration.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
id: ID of the log alert configuration to disable
|
|
127
|
+
ctx: The MCP context (optional)
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Dictionary containing the result of the disable operation or error information
|
|
131
|
+
"""
|
|
132
|
+
try:
|
|
133
|
+
logger.debug(f"disable_log_alert_config called with id={id}")
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
self.log_alert_api.disable_log_alert_config(id=id)
|
|
137
|
+
logger.debug(f"Successfully disabled log alert configuration with ID {id}")
|
|
138
|
+
return {"success": True, "message": f"Log alert configuration with ID {id} disabled successfully"}
|
|
139
|
+
except Exception as e:
|
|
140
|
+
logger.error(f"Error calling disable_log_alert_config API: {e}", exc_info=True)
|
|
141
|
+
return {"error": f"Failed to disable log alert configuration: {e!s}"}
|
|
142
|
+
except Exception as e:
|
|
143
|
+
logger.error(f"Error in disable_log_alert_config: {e}", exc_info=True)
|
|
144
|
+
return {"error": f"Failed to disable log alert configuration: {e!s}"}
|
|
145
|
+
|
|
146
|
+
@register_as_tool
|
|
147
|
+
async def enable_log_alert_config(self, id: str, ctx=None) -> Dict[str, Any]:
|
|
148
|
+
"""
|
|
149
|
+
Enable a log alert configuration.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
id: ID of the log alert configuration to enable
|
|
153
|
+
ctx: The MCP context (optional)
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
Dictionary containing the result of the enable operation or error information
|
|
157
|
+
"""
|
|
158
|
+
try:
|
|
159
|
+
logger.debug(f"enable_log_alert_config called with id={id}")
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
self.log_alert_api.enable_log_alert_config(id=id)
|
|
163
|
+
logger.debug(f"Successfully enabled log alert configuration with ID {id}")
|
|
164
|
+
return {"success": True, "message": f"Log alert configuration with ID {id} enabled successfully"}
|
|
165
|
+
except Exception as e:
|
|
166
|
+
logger.error(f"Error calling enable_log_alert_config API: {e}", exc_info=True)
|
|
167
|
+
return {"error": f"Failed to enable log alert configuration: {e!s}"}
|
|
168
|
+
except Exception as e:
|
|
169
|
+
logger.error(f"Error in enable_log_alert_config: {e}", exc_info=True)
|
|
170
|
+
return {"error": f"Failed to enable log alert configuration: {e!s}"}
|
|
171
|
+
|
|
172
|
+
@register_as_tool
|
|
173
|
+
async def find_active_log_alert_configs(self, alert_ids: Optional[List[str]] = None, ctx=None) -> Dict[str, Any]:
|
|
174
|
+
"""
|
|
175
|
+
Get all active log alert configurations.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
alert_ids: Optional list of alert IDs to filter by
|
|
179
|
+
ctx: The MCP context (optional)
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Dictionary containing active log alert configurations or error information
|
|
183
|
+
"""
|
|
184
|
+
try:
|
|
185
|
+
logger.debug(f"find_active_log_alert_configs called with alert_ids={alert_ids}")
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
result = self.log_alert_api.find_active_log_alert_configs(alert_ids=alert_ids)
|
|
189
|
+
logger.debug(f"Result from find_active_log_alert_configs: {result}")
|
|
190
|
+
return {"configs": [self._convert_to_dict(config) for config in result]}
|
|
191
|
+
except Exception as e:
|
|
192
|
+
logger.error(f"Error calling find_active_log_alert_configs API: {e}", exc_info=True)
|
|
193
|
+
return {"error": f"Failed to find active log alert configurations: {e!s}"}
|
|
194
|
+
except Exception as e:
|
|
195
|
+
logger.error(f"Error in find_active_log_alert_configs: {e}", exc_info=True)
|
|
196
|
+
return {"error": f"Failed to find active log alert configurations: {e!s}"}
|
|
197
|
+
|
|
198
|
+
@register_as_tool
|
|
199
|
+
async def find_log_alert_config(self, id: str, valid_on: Optional[int] = None, ctx=None) -> Dict[str, Any]:
|
|
200
|
+
"""
|
|
201
|
+
Get a specific log alert configuration by ID.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
id: ID of the log alert configuration to retrieve
|
|
205
|
+
valid_on: Optional timestamp to get the configuration valid at that time
|
|
206
|
+
ctx: The MCP context (optional)
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Dictionary containing the log alert configuration or error information
|
|
210
|
+
"""
|
|
211
|
+
try:
|
|
212
|
+
logger.debug(f"find_log_alert_config called with id={id}, valid_on={valid_on}")
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
result = self.log_alert_api.find_log_alert_config(id=id, valid_on=valid_on)
|
|
216
|
+
logger.debug(f"Result from find_log_alert_config: {result}")
|
|
217
|
+
return self._convert_to_dict(result)
|
|
218
|
+
except Exception as e:
|
|
219
|
+
logger.error(f"Error calling find_log_alert_config API: {e}", exc_info=True)
|
|
220
|
+
return {"error": f"Failed to find log alert configuration: {e!s}"}
|
|
221
|
+
except Exception as e:
|
|
222
|
+
logger.error(f"Error in find_log_alert_config: {e}", exc_info=True)
|
|
223
|
+
return {"error": f"Failed to find log alert configuration: {e!s}"}
|
|
224
|
+
|
|
225
|
+
@register_as_tool
|
|
226
|
+
async def find_log_alert_config_versions(self, id: str, ctx=None) -> Dict[str, Any]:
|
|
227
|
+
"""
|
|
228
|
+
Get all versions of a log alert configuration.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
id: ID of the log alert configuration to get versions for
|
|
232
|
+
ctx: The MCP context (optional)
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
Dictionary containing versions of the log alert configuration or error information
|
|
236
|
+
"""
|
|
237
|
+
try:
|
|
238
|
+
logger.debug(f"find_log_alert_config_versions called with id={id}")
|
|
239
|
+
|
|
240
|
+
try:
|
|
241
|
+
result = self.log_alert_api.find_log_alert_config_versions(id=id)
|
|
242
|
+
logger.debug(f"Result from find_log_alert_config_versions: {result}")
|
|
243
|
+
return {"versions": [self._convert_to_dict(version) for version in result]}
|
|
244
|
+
except Exception as e:
|
|
245
|
+
logger.error(f"Error calling find_log_alert_config_versions API: {e}", exc_info=True)
|
|
246
|
+
return {"error": f"Failed to find log alert configuration versions: {e!s}"}
|
|
247
|
+
except Exception as e:
|
|
248
|
+
logger.error(f"Error in find_log_alert_config_versions: {e}", exc_info=True)
|
|
249
|
+
return {"error": f"Failed to find log alert configuration versions: {e!s}"}
|
|
250
|
+
|
|
251
|
+
@register_as_tool
|
|
252
|
+
async def restore_log_alert_config(self, id: str, created: int, ctx=None) -> Dict[str, Any]:
|
|
253
|
+
"""
|
|
254
|
+
Restore a log alert configuration to a previous version.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
id: ID of the log alert configuration to restore
|
|
258
|
+
created: Timestamp of the version to restore
|
|
259
|
+
ctx: The MCP context (optional)
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
Dictionary containing the result of the restore operation or error information
|
|
263
|
+
"""
|
|
264
|
+
try:
|
|
265
|
+
logger.debug(f"restore_log_alert_config called with id={id}, created={created}")
|
|
266
|
+
|
|
267
|
+
try:
|
|
268
|
+
self.log_alert_api.restore_log_alert_config(id=id, created=created)
|
|
269
|
+
logger.debug(f"Successfully restored log alert configuration with ID {id}")
|
|
270
|
+
return {
|
|
271
|
+
"success": True,
|
|
272
|
+
"message": f"Log alert configuration with ID {id} restored to version from {datetime.fromtimestamp(created/1000).isoformat()}"
|
|
273
|
+
}
|
|
274
|
+
except Exception as e:
|
|
275
|
+
logger.error(f"Error calling restore_log_alert_config API: {e}", exc_info=True)
|
|
276
|
+
return {"error": f"Failed to restore log alert configuration: {e!s}"}
|
|
277
|
+
except Exception as e:
|
|
278
|
+
logger.error(f"Error in restore_log_alert_config: {e}", exc_info=True)
|
|
279
|
+
return {"error": f"Failed to restore log alert configuration: {e!s}"}
|
|
280
|
+
|
|
281
|
+
@register_as_tool
|
|
282
|
+
async def update_log_alert_config(self, id: str, config: Dict[str, Any], ctx=None) -> Dict[str, Any]:
|
|
283
|
+
"""
|
|
284
|
+
Update a log alert configuration.
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
id: ID of the log alert configuration to update
|
|
288
|
+
config: Dictionary containing the updated log alert configuration
|
|
289
|
+
ctx: The MCP context (optional)
|
|
290
|
+
|
|
291
|
+
Returns:
|
|
292
|
+
Dictionary containing the updated log alert configuration or error information
|
|
293
|
+
"""
|
|
294
|
+
try:
|
|
295
|
+
logger.debug(f"update_log_alert_config called with id={id}, config={config}")
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
# Convert dictionary to LogAlertConfig model
|
|
299
|
+
log_alert_config = LogAlertConfig(**config)
|
|
300
|
+
except Exception as e:
|
|
301
|
+
logger.error(f"Error creating LogAlertConfig: {e}", exc_info=True)
|
|
302
|
+
return {"error": f"Failed to update log alert configuration: {e!s}"}
|
|
303
|
+
|
|
304
|
+
try:
|
|
305
|
+
# Call the API
|
|
306
|
+
result = self.log_alert_api.update_log_alert_config(id=id, log_alert_config=log_alert_config)
|
|
307
|
+
logger.debug(f"Result from update_log_alert_config: {result}")
|
|
308
|
+
return self._convert_to_dict(result)
|
|
309
|
+
except Exception as e:
|
|
310
|
+
logger.error(f"Error calling update_log_alert_config API: {e}", exc_info=True)
|
|
311
|
+
return {"error": f"Failed to update log alert configuration: {e!s}"}
|
|
312
|
+
except Exception as e:
|
|
313
|
+
logger.error(f"Error in update_log_alert_config: {e}", exc_info=True)
|
|
314
|
+
return {"error": f"Failed to update log alert configuration: {e!s}"}
|
|
315
|
+
|
|
316
|
+
def _convert_to_dict(self, obj: Any) -> Dict[str, Any]:
|
|
317
|
+
"""
|
|
318
|
+
Convert an object to a dictionary.
|
|
319
|
+
|
|
320
|
+
Args:
|
|
321
|
+
obj: Object to convert
|
|
322
|
+
|
|
323
|
+
Returns:
|
|
324
|
+
Dictionary representation of the object
|
|
325
|
+
"""
|
|
326
|
+
if hasattr(obj, "to_dict"):
|
|
327
|
+
return obj.to_dict()
|
|
328
|
+
elif hasattr(obj, "__dict__"):
|
|
329
|
+
return obj.__dict__
|
|
330
|
+
else:
|
|
331
|
+
return obj
|