Skip to content

Commit cf403ff

Browse files
feat: Added next steps for get_entity_details tool (#130)
1 parent 45091a9 commit cf403ff

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased Changes
44

55
- Added metadata output which includes scanned bytes (for cost tracking) to `execute_dql`
6+
- Added next-steps for `get_entity_details` to find out about metrics, problems and logs
67

78
## 0.5.0
89

src/capabilities/get-monitored-entity-details.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { HttpClient } from '@dynatrace-sdk/http-client';
22
import { executeDql } from './execute-dql';
33
import { getEntityTypeFromId } from '../utils/dynatrace-entity-types';
44

5-
type MonitoredEntityDetails = { entityId: string; displayName: string; type: string; allProperties: any };
5+
type MonitoredEntityDetails = {
6+
entityId: string;
7+
displayName: string;
8+
entityTypeTable: string;
9+
type: string;
10+
allProperties: any;
11+
};
612

713
/**
814
* Get monitored entity details by entity ID via DQL
@@ -53,6 +59,7 @@ export const getMonitoredEntityDetails = async (
5359
// return entity details
5460
return {
5561
entityId: String(entity.id),
62+
entityTypeTable: entityType,
5663
displayName: String(entity['entity.name']),
5764
type: String(entity['entity.type']),
5865
allProperties: entity || undefined,

src/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
generateDqlFromNaturalLanguage,
4242
} from './capabilities/davis-copilot';
4343
import { DynatraceEnv, getDynatraceEnv } from './getDynatraceEnv';
44+
import { getEntityTypeFromId } from './utils/dynatrace-entity-types';
4445

4546
config();
4647

@@ -367,6 +368,20 @@ const main = async () => {
367368
resp += `You can find more details about the application at ${dtEnvironment}/ui/apps/dynatrace.kubernetes/explorer/workload?detailsId=${entityDetails.entityId}`;
368369
}
369370

371+
resp += `\n\n**Filter**:`;
372+
373+
// Use entityTypeTable as the filter (e.g., fetch logs | filter dt.entity.service == "SERVICE-1234")
374+
if (entityDetails.entityTypeTable) {
375+
resp += ` You can use the following filter to get relevant information from other tools: \`| filter ${entityDetails.entityTypeTable} == "${entityDetails.entityId}"\`. `;
376+
} else {
377+
resp += ` Try to use search command as follows: \`| search "${entityDetails.entityId}"\`. `;
378+
}
379+
380+
resp += `\n\n**Next Steps**\n\n`;
381+
resp += `1. Find available metrics for this entity, by using execute_dql tool with the following DQL statement: "fetch metric.series" and the filter defined above\n`;
382+
resp += `2. Find out whether any problems exist for this entity using the list_problems tool\n`;
383+
resp += `3. Explore logs for this entity by using execute_dql with "fetch logs" and applying the filter mentioned above'\n`;
384+
370385
return resp;
371386
},
372387
);
@@ -430,13 +445,13 @@ const main = async () => {
430445
tool(
431446
'execute_dql',
432447
'Get Logs, Metrics, Spans or Events from Dynatrace GRAIL by executing a Dynatrace Query Language (DQL) statement. ' +
433-
'You can also use "generate_dql_from_natural_language" to generate a DQL statement based on your request. ' +
448+
'You can also use the "generate_dql_from_natural_language" tool upfront to generate or refine a DQL statement based on your request. ' +
434449
'Note: For more information about available fields for filters and aggregation, use the query "fetch dt.semantic_dictionary.models | filter data_object == \"logs\""',
435450
{
436451
dqlStatement: z
437452
.string()
438453
.describe(
439-
'DQL Statement (Ex: "fetch [logs, spans, events] | filter <some-filter> | summarize count(), by:{some-fields}.", "timeseries { avg(<metric-name>), value.A = avg(<metric-name>, scalar: true) }")',
454+
'DQL Statement (Ex: "fetch [logs, spans, events] | filter <some-filter> | summarize count(), by:{some-fields}.", or for metrics: "timeseries { avg(<metric-name>), value.A = avg(<metric-name>, scalar: true) }")',
440455
),
441456
},
442457
async ({ dqlStatement }) => {

0 commit comments

Comments
 (0)