mcp-instana 0.1.0__py3-none-any.whl → 0.2.0__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.2.0.dist-info/METADATA +1229 -0
- mcp_instana-0.2.0.dist-info/RECORD +59 -0
- {mcp_instana-0.1.0.dist-info → mcp_instana-0.2.0.dist-info}/WHEEL +1 -1
- mcp_instana-0.2.0.dist-info/entry_points.txt +4 -0
- mcp_instana-0.1.0.dist-info/LICENSE → mcp_instana-0.2.0.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 +628 -0
- src/application/application_catalog.py +155 -0
- src/application/application_global_alert_config.py +653 -0
- src/{client/application_metrics_mcp_tools.py → application/application_metrics.py} +113 -131
- src/{client/application_resources_mcp_tools.py → application/application_resources.py} +131 -151
- src/application/application_settings.py +1731 -0
- src/application/application_topology.py +111 -0
- src/automation/action_catalog.py +416 -0
- src/automation/action_history.py +338 -0
- src/core/__init__.py +1 -0
- src/core/server.py +586 -0
- src/core/utils.py +213 -0
- src/event/__init__.py +1 -0
- src/event/events_tools.py +850 -0
- src/infrastructure/__init__.py +1 -0
- src/{client/infrastructure_analyze_mcp_tools.py → infrastructure/infrastructure_analyze.py} +207 -206
- src/{client/infrastructure_catalog_mcp_tools.py → infrastructure/infrastructure_catalog.py} +197 -265
- src/infrastructure/infrastructure_metrics.py +171 -0
- src/{client/infrastructure_resources_mcp_tools.py → infrastructure/infrastructure_resources.py} +198 -227
- src/{client/infrastructure_topology_mcp_tools.py → infrastructure/infrastructure_topology.py} +110 -109
- src/log/__init__.py +1 -0
- src/log/log_alert_configuration.py +331 -0
- src/prompts/__init__.py +16 -0
- src/prompts/application/__init__.py +1 -0
- src/prompts/application/application_alerts.py +54 -0
- src/prompts/application/application_catalog.py +26 -0
- src/prompts/application/application_metrics.py +57 -0
- src/prompts/application/application_resources.py +26 -0
- src/prompts/application/application_settings.py +75 -0
- src/prompts/application/application_topology.py +30 -0
- src/prompts/events/__init__.py +1 -0
- src/prompts/events/events_tools.py +161 -0
- src/prompts/infrastructure/infrastructure_analyze.py +72 -0
- src/prompts/infrastructure/infrastructure_catalog.py +53 -0
- src/prompts/infrastructure/infrastructure_metrics.py +45 -0
- src/prompts/infrastructure/infrastructure_resources.py +74 -0
- src/prompts/infrastructure/infrastructure_topology.py +38 -0
- src/prompts/settings/__init__.py +0 -0
- src/prompts/settings/custom_dashboard.py +157 -0
- src/prompts/website/__init__.py +1 -0
- src/prompts/website/website_analyze.py +35 -0
- src/prompts/website/website_catalog.py +40 -0
- src/prompts/website/website_configuration.py +105 -0
- src/prompts/website/website_metrics.py +34 -0
- src/settings/__init__.py +1 -0
- src/settings/custom_dashboard_tools.py +417 -0
- src/website/__init__.py +0 -0
- src/website/website_analyze.py +433 -0
- src/website/website_catalog.py +171 -0
- src/website/website_configuration.py +770 -0
- src/website/website_metrics.py +241 -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/events_mcp_tools.py +0 -531
- 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
|
@@ -4,71 +4,54 @@ Application Metrics MCP Tools Module
|
|
|
4
4
|
This module provides application metrics-specific MCP tools for Instana monitoring.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import traceback
|
|
9
|
-
from typing import Dict, Any, Optional, List, Union
|
|
7
|
+
import logging
|
|
10
8
|
from datetime import datetime
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
11
10
|
|
|
12
11
|
# Import the necessary classes from the SDK
|
|
13
12
|
try:
|
|
14
|
-
from instana_client.api.application_metrics_api import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
from instana_client.models.get_application_metrics import
|
|
13
|
+
from instana_client.api.application_metrics_api import (
|
|
14
|
+
ApplicationMetricsApi,
|
|
15
|
+
)
|
|
16
|
+
from instana_client.models.get_application_metrics import (
|
|
17
|
+
GetApplicationMetrics,
|
|
18
|
+
)
|
|
18
19
|
from instana_client.models.get_applications import GetApplications
|
|
19
20
|
from instana_client.models.get_endpoints import GetEndpoints
|
|
20
21
|
from instana_client.models.get_services import GetServices
|
|
21
22
|
except ImportError as e:
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
import logging
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
logger.error(f"Error importing Instana SDK: {e}", exc_info=True)
|
|
24
26
|
raise
|
|
25
27
|
|
|
26
|
-
from .
|
|
28
|
+
from src.core.utils import BaseInstanaClient, register_as_tool, with_header_auth
|
|
27
29
|
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
"""Print debug information to stderr instead of stdout"""
|
|
31
|
-
print(*args, file=sys.stderr, **kwargs)
|
|
30
|
+
# Configure logger for this module
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
32
|
|
|
33
33
|
class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
34
34
|
"""Tools for application metrics in Instana MCP."""
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
def __init__(self, read_token: str, base_url: str):
|
|
37
37
|
"""Initialize the Application Metrics MCP tools client."""
|
|
38
38
|
super().__init__(read_token=read_token, base_url=base_url)
|
|
39
|
-
|
|
40
|
-
try:
|
|
41
|
-
|
|
42
|
-
# Configure the API client with the correct base URL and authentication
|
|
43
|
-
configuration = Configuration()
|
|
44
|
-
configuration.host = base_url
|
|
45
|
-
configuration.api_key['ApiKeyAuth'] = read_token
|
|
46
|
-
configuration.api_key_prefix['ApiKeyAuth'] = 'apiToken'
|
|
47
|
-
|
|
48
|
-
# Create an API client with this configuration
|
|
49
|
-
api_client = ApiClient(configuration=configuration)
|
|
50
|
-
|
|
51
|
-
# Initialize the Instana SDK's ApplicationMetricsApi with our configured client
|
|
52
|
-
self.metrics_api = ApplicationMetricsApi(api_client=api_client)
|
|
53
|
-
except Exception as e:
|
|
54
|
-
debug_print(f"Error initializing ApplicationMetricsApi: {e}")
|
|
55
|
-
traceback.print_exc(file=sys.stderr)
|
|
56
|
-
raise
|
|
57
|
-
|
|
39
|
+
|
|
58
40
|
@register_as_tool
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
41
|
+
@with_header_auth(ApplicationMetricsApi)
|
|
42
|
+
async def get_application_data_metrics_v2(self,
|
|
43
|
+
metrics: Optional[List[Dict[str, Any]]] = None,
|
|
44
|
+
time_frame: Optional[Dict[str, int]] = None,
|
|
45
|
+
application_id: Optional[str] = None,
|
|
46
|
+
service_id: Optional[str] = None,
|
|
47
|
+
endpoint_id: Optional[str] = None,
|
|
48
|
+
ctx=None, api_client=None) -> Dict[str, Any]:
|
|
66
49
|
"""
|
|
67
50
|
Get application data metrics using the v2 API.
|
|
68
|
-
|
|
51
|
+
|
|
69
52
|
This API endpoint retrieves one or more supported aggregations of metrics for a combination of entities.
|
|
70
53
|
For example, retrieve MEAN aggregation of latency metric for an Endpoint, Service, and Application.
|
|
71
|
-
|
|
54
|
+
|
|
72
55
|
Args:
|
|
73
56
|
metrics: List of metrics to retrieve with their aggregations
|
|
74
57
|
Example: [{"metric": "latency", "aggregation": "MEAN"}]
|
|
@@ -78,13 +61,13 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
78
61
|
service_id: ID of the service to get metrics for (optional)
|
|
79
62
|
endpoint_id: ID of the endpoint to get metrics for (optional)
|
|
80
63
|
ctx: The MCP context (optional)
|
|
81
|
-
|
|
64
|
+
|
|
82
65
|
Returns:
|
|
83
66
|
Dictionary containing metrics data or error information
|
|
84
67
|
"""
|
|
85
68
|
try:
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
logger.debug(f"get_application_data_metrics_v2 called with application_id={application_id}, service_id={service_id}, endpoint_id={endpoint_id}")
|
|
70
|
+
|
|
88
71
|
# Set default time range if not provided
|
|
89
72
|
if not time_frame:
|
|
90
73
|
to_time = int(datetime.now().timestamp() * 1000)
|
|
@@ -93,7 +76,7 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
93
76
|
"from": from_time,
|
|
94
77
|
"to": to_time
|
|
95
78
|
}
|
|
96
|
-
|
|
79
|
+
|
|
97
80
|
# Set default metrics if not provided
|
|
98
81
|
if not metrics:
|
|
99
82
|
metrics = [
|
|
@@ -102,13 +85,13 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
102
85
|
"aggregation": "MEAN"
|
|
103
86
|
}
|
|
104
87
|
]
|
|
105
|
-
|
|
88
|
+
|
|
106
89
|
# Create the request body
|
|
107
90
|
request_body = {
|
|
108
91
|
"metrics": metrics,
|
|
109
92
|
"timeFrame": time_frame
|
|
110
93
|
}
|
|
111
|
-
|
|
94
|
+
|
|
112
95
|
# Add entity IDs if provided
|
|
113
96
|
if application_id:
|
|
114
97
|
request_body["applicationId"] = application_id
|
|
@@ -116,41 +99,41 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
116
99
|
request_body["serviceId"] = service_id
|
|
117
100
|
if endpoint_id:
|
|
118
101
|
request_body["endpointId"] = endpoint_id
|
|
119
|
-
|
|
102
|
+
|
|
120
103
|
# Create the GetApplicationMetrics object
|
|
121
104
|
get_app_metrics = GetApplicationMetrics(**request_body)
|
|
122
|
-
|
|
105
|
+
|
|
123
106
|
# Call the get_application_data_metrics_v2 method from the SDK
|
|
124
|
-
result =
|
|
107
|
+
result = api_client.get_application_data_metrics_v2(
|
|
125
108
|
get_application_metrics=get_app_metrics
|
|
126
109
|
)
|
|
127
|
-
|
|
110
|
+
|
|
128
111
|
# Convert the result to a dictionary
|
|
129
112
|
if hasattr(result, 'to_dict'):
|
|
130
113
|
result_dict = result.to_dict()
|
|
131
114
|
else:
|
|
132
115
|
# If it's already a dict or another format, use it as is
|
|
133
116
|
result_dict = result
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
|
|
118
|
+
logger.debug(f"Result from get_application_data_metrics_v2: {result_dict}")
|
|
136
119
|
return result_dict
|
|
137
120
|
except Exception as e:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
logger.error(f"Error in get_application_data_metrics_v2: {e}", exc_info=True)
|
|
122
|
+
return {"error": f"Failed to get application data metrics: {e!s}"}
|
|
123
|
+
|
|
142
124
|
@register_as_tool
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
@with_header_auth(ApplicationMetricsApi)
|
|
126
|
+
async def get_application_metrics(self,
|
|
127
|
+
application_ids: Optional[List[str]] = None,
|
|
128
|
+
metrics: Optional[List[Dict[str, str]]] = None,
|
|
129
|
+
time_frame: Optional[Dict[str, int]] = None,
|
|
130
|
+
fill_time_series: Optional[bool] = True,
|
|
131
|
+
ctx=None, api_client=None) -> Dict[str, Any]:
|
|
149
132
|
"""
|
|
150
133
|
Get metrics for specific applications.
|
|
151
|
-
|
|
134
|
+
|
|
152
135
|
This API endpoint retrieves one or more supported aggregations of metrics for an Application Perspective.
|
|
153
|
-
|
|
136
|
+
|
|
154
137
|
Args:
|
|
155
138
|
application_ids: List of application IDs to get metrics for
|
|
156
139
|
metrics: List of metrics to retrieve with their aggregations
|
|
@@ -159,13 +142,13 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
159
142
|
Example: {"from": 1617994800000, "to": 1618081200000}
|
|
160
143
|
fill_time_series: Whether to fill missing data points with timestamp and value 0
|
|
161
144
|
ctx: The MCP context (optional)
|
|
162
|
-
|
|
145
|
+
|
|
163
146
|
Returns:
|
|
164
147
|
Dictionary containing application metrics data or error information
|
|
165
148
|
"""
|
|
166
149
|
try:
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
logger.debug(f"get_application_metrics called with application_ids={application_ids}")
|
|
151
|
+
|
|
169
152
|
# Set default time range if not provided
|
|
170
153
|
if not time_frame:
|
|
171
154
|
to_time = int(datetime.now().timestamp() * 1000)
|
|
@@ -174,7 +157,7 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
174
157
|
"from": from_time,
|
|
175
158
|
"to": to_time
|
|
176
159
|
}
|
|
177
|
-
|
|
160
|
+
|
|
178
161
|
# Set default metrics if not provided
|
|
179
162
|
if not metrics:
|
|
180
163
|
metrics = [
|
|
@@ -183,52 +166,52 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
183
166
|
"aggregation": "MEAN"
|
|
184
167
|
}
|
|
185
168
|
]
|
|
186
|
-
|
|
169
|
+
|
|
187
170
|
# Create the request body
|
|
188
171
|
request_body = {
|
|
189
172
|
"metrics": metrics,
|
|
190
173
|
"timeFrame": time_frame
|
|
191
174
|
}
|
|
192
|
-
|
|
175
|
+
|
|
193
176
|
# Add application IDs if provided
|
|
194
177
|
if application_ids:
|
|
195
178
|
request_body["applicationIds"] = application_ids
|
|
196
|
-
|
|
179
|
+
|
|
197
180
|
# Create the GetApplications object
|
|
198
181
|
get_applications = GetApplications(**request_body)
|
|
199
|
-
|
|
182
|
+
|
|
200
183
|
# Call the get_application_metrics method from the SDK
|
|
201
|
-
result =
|
|
184
|
+
result = api_client.get_application_metrics(
|
|
202
185
|
fill_time_series=fill_time_series,
|
|
203
186
|
get_applications=get_applications
|
|
204
187
|
)
|
|
205
|
-
|
|
188
|
+
|
|
206
189
|
# Convert the result to a dictionary
|
|
207
190
|
if hasattr(result, 'to_dict'):
|
|
208
191
|
result_dict = result.to_dict()
|
|
209
192
|
else:
|
|
210
193
|
# If it's already a dict or another format, use it as is
|
|
211
194
|
result_dict = result
|
|
212
|
-
|
|
213
|
-
|
|
195
|
+
|
|
196
|
+
logger.debug(f"Result from get_application_metrics: {result_dict}")
|
|
214
197
|
return result_dict
|
|
215
198
|
except Exception as e:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
199
|
+
logger.error(f"Error in get_application_metrics: {e}", exc_info=True)
|
|
200
|
+
return {"error": f"Failed to get application metrics: {e!s}"}
|
|
201
|
+
|
|
220
202
|
@register_as_tool
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
203
|
+
@with_header_auth(ApplicationMetricsApi)
|
|
204
|
+
async def get_endpoints_metrics(self,
|
|
205
|
+
endpoint_ids: Optional[List[str]] = None,
|
|
206
|
+
metrics: Optional[List[Dict[str, str]]] = None,
|
|
207
|
+
time_frame: Optional[Dict[str, int]] = None,
|
|
208
|
+
fill_time_series: Optional[bool] = True,
|
|
209
|
+
ctx=None, api_client=None) -> Dict[str, Any]:
|
|
227
210
|
"""
|
|
228
211
|
Get metrics for specific endpoints.
|
|
229
|
-
|
|
212
|
+
|
|
230
213
|
This API endpoint retrieves one or more supported aggregations of metrics for an Endpoint.
|
|
231
|
-
|
|
214
|
+
|
|
232
215
|
Args:
|
|
233
216
|
endpoint_ids: List of endpoint IDs to get metrics for
|
|
234
217
|
metrics: List of metrics to retrieve with their aggregations
|
|
@@ -237,13 +220,13 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
237
220
|
Example: {"from": 1617994800000, "to": 1618081200000}
|
|
238
221
|
fill_time_series: Whether to fill missing data points with timestamp and value 0
|
|
239
222
|
ctx: The MCP context (optional)
|
|
240
|
-
|
|
223
|
+
|
|
241
224
|
Returns:
|
|
242
225
|
Dictionary containing endpoint metrics data or error information
|
|
243
226
|
"""
|
|
244
227
|
try:
|
|
245
|
-
|
|
246
|
-
|
|
228
|
+
logger.debug(f"get_endpoints_metrics called with endpoint_ids={endpoint_ids}")
|
|
229
|
+
|
|
247
230
|
# Set default time range if not provided
|
|
248
231
|
if not time_frame:
|
|
249
232
|
to_time = int(datetime.now().timestamp() * 1000)
|
|
@@ -252,7 +235,7 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
252
235
|
"from": from_time,
|
|
253
236
|
"to": to_time
|
|
254
237
|
}
|
|
255
|
-
|
|
238
|
+
|
|
256
239
|
# Set default metrics if not provided
|
|
257
240
|
if not metrics:
|
|
258
241
|
metrics = [
|
|
@@ -261,53 +244,53 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
261
244
|
"aggregation": "MEAN"
|
|
262
245
|
}
|
|
263
246
|
]
|
|
264
|
-
|
|
247
|
+
|
|
265
248
|
# Create the request body
|
|
266
249
|
request_body = {
|
|
267
250
|
"metrics": metrics,
|
|
268
251
|
"timeFrame": time_frame
|
|
269
252
|
}
|
|
270
|
-
|
|
253
|
+
|
|
271
254
|
# Add endpoint IDs if provided
|
|
272
255
|
if endpoint_ids:
|
|
273
256
|
request_body["endpointIds"] = endpoint_ids
|
|
274
|
-
|
|
257
|
+
|
|
275
258
|
# Create the GetEndpoints object
|
|
276
259
|
get_endpoints = GetEndpoints(**request_body)
|
|
277
|
-
|
|
260
|
+
|
|
278
261
|
# Call the get_endpoints_metrics method from the SDK
|
|
279
|
-
result =
|
|
262
|
+
result = api_client.get_endpoints_metrics(
|
|
280
263
|
fill_time_series=fill_time_series,
|
|
281
264
|
get_endpoints=get_endpoints
|
|
282
265
|
)
|
|
283
|
-
|
|
266
|
+
|
|
284
267
|
# Convert the result to a dictionary
|
|
285
268
|
if hasattr(result, 'to_dict'):
|
|
286
269
|
result_dict = result.to_dict()
|
|
287
270
|
else:
|
|
288
271
|
# If it's already a dict or another format, use it as is
|
|
289
272
|
result_dict = result
|
|
290
|
-
|
|
291
|
-
|
|
273
|
+
|
|
274
|
+
logger.debug(f"Result from get_endpoints_metrics: {result_dict}")
|
|
292
275
|
return result_dict
|
|
293
276
|
except Exception as e:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
277
|
+
logger.error(f"Error in get_endpoints_metrics: {e}", exc_info=True)
|
|
278
|
+
return {"error": f"Failed to get endpoints metrics: {e!s}"}
|
|
279
|
+
|
|
298
280
|
@register_as_tool
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
281
|
+
@with_header_auth(ApplicationMetricsApi)
|
|
282
|
+
async def get_services_metrics(self,
|
|
283
|
+
service_ids: Optional[List[str]] = None,
|
|
284
|
+
metrics: Optional[List[Dict[str, str]]] = None,
|
|
285
|
+
time_frame: Optional[Dict[str, int]] = None,
|
|
286
|
+
fill_time_series: Optional[bool] = True,
|
|
287
|
+
include_snapshot_ids: Optional[bool] = False,
|
|
288
|
+
ctx=None, api_client=None) -> Dict[str, Any]:
|
|
306
289
|
"""
|
|
307
290
|
Get metrics for specific services.
|
|
308
|
-
|
|
291
|
+
|
|
309
292
|
This API endpoint retrieves one or more supported aggregations of metrics for a Service.
|
|
310
|
-
|
|
293
|
+
|
|
311
294
|
Args:
|
|
312
295
|
service_ids: List of service IDs to get metrics for
|
|
313
296
|
metrics: List of metrics to retrieve with their aggregations
|
|
@@ -317,13 +300,13 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
317
300
|
fill_time_series: Whether to fill missing data points with timestamp and value 0
|
|
318
301
|
include_snapshot_ids: Whether to include snapshot IDs in the results
|
|
319
302
|
ctx: The MCP context (optional)
|
|
320
|
-
|
|
303
|
+
|
|
321
304
|
Returns:
|
|
322
305
|
Dictionary containing service metrics data or error information
|
|
323
306
|
"""
|
|
324
307
|
try:
|
|
325
|
-
|
|
326
|
-
|
|
308
|
+
logger.debug(f"get_services_metrics called with service_ids={service_ids}")
|
|
309
|
+
|
|
327
310
|
# Set default time range if not provided
|
|
328
311
|
if not time_frame:
|
|
329
312
|
to_time = int(datetime.now().timestamp() * 1000)
|
|
@@ -332,7 +315,7 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
332
315
|
"from": from_time,
|
|
333
316
|
"to": to_time
|
|
334
317
|
}
|
|
335
|
-
|
|
318
|
+
|
|
336
319
|
# Set default metrics if not provided
|
|
337
320
|
if not metrics:
|
|
338
321
|
metrics = [
|
|
@@ -341,37 +324,36 @@ class ApplicationMetricsMCPTools(BaseInstanaClient):
|
|
|
341
324
|
"aggregation": "MEAN"
|
|
342
325
|
}
|
|
343
326
|
]
|
|
344
|
-
|
|
327
|
+
|
|
345
328
|
# Create the request body
|
|
346
329
|
request_body = {
|
|
347
330
|
"metrics": metrics,
|
|
348
331
|
"timeFrame": time_frame
|
|
349
332
|
}
|
|
350
|
-
|
|
333
|
+
|
|
351
334
|
# Add service IDs if provided
|
|
352
335
|
if service_ids:
|
|
353
336
|
request_body["serviceIds"] = service_ids
|
|
354
|
-
|
|
337
|
+
|
|
355
338
|
# Create the GetServices object
|
|
356
339
|
get_services = GetServices(**request_body)
|
|
357
|
-
|
|
340
|
+
|
|
358
341
|
# Call the get_services_metrics method from the SDK
|
|
359
|
-
result =
|
|
342
|
+
result = api_client.get_services_metrics(
|
|
360
343
|
fill_time_series=fill_time_series,
|
|
361
344
|
include_snapshot_ids=include_snapshot_ids,
|
|
362
345
|
get_services=get_services
|
|
363
346
|
)
|
|
364
|
-
|
|
347
|
+
|
|
365
348
|
# Convert the result to a dictionary
|
|
366
349
|
if hasattr(result, 'to_dict'):
|
|
367
350
|
result_dict = result.to_dict()
|
|
368
351
|
else:
|
|
369
352
|
# If it's already a dict or another format, use it as is
|
|
370
353
|
result_dict = result
|
|
371
|
-
|
|
372
|
-
|
|
354
|
+
|
|
355
|
+
logger.debug(f"Result from get_services_metrics: {result_dict}")
|
|
373
356
|
return result_dict
|
|
374
357
|
except Exception as e:
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return {"error": f"Failed to get services metrics: {str(e)}"}
|
|
358
|
+
logger.error(f"Error in get_services_metrics: {e}", exc_info=True)
|
|
359
|
+
return {"error": f"Failed to get services metrics: {e!s}"}
|