Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/sim/blocks/blocks/new_relic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,17 @@ Return ONLY the numeric timestamp - no explanations, no extra text.`,
resultCount: { type: 'number', description: 'Number of NRQL result rows' },
count: { type: 'number', description: 'Number of matching entities' },
query: { type: 'string', description: 'Entity search query New Relic executed' },
entities: { type: 'json', description: 'Matching New Relic entities (guid, name, entityType)' },
entities: {
type: 'json',
description:
'Matching New Relic entities (guid, name, entityType, domain, reporting, alertSeverity, tags)',
},
nextCursor: { type: 'string', description: 'Cursor for the next entity search page' },
entity: { type: 'json', description: 'New Relic entity details (guid, name, entityType)' },
entity: {
type: 'json',
description:
'New Relic entity details (guid, name, entityType, domain, reporting, alertSeverity, tags)',
},
event: { type: 'json', description: 'Created change tracking event metadata' },
messages: { type: 'json', description: 'New Relic change tracking messages' },
},
Expand Down
44 changes: 35 additions & 9 deletions apps/sim/tools/new_relic/get_entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import type { NewRelicGetEntityParams, NewRelicGetEntityResponse } from '@/tools
import {
getNerdGraphEndpoint,
gqlString,
type NewRelicRawEntity,
newRelicHeaders,
normalizeNewRelicEntity,
parseNerdGraphResponse,
} from '@/tools/new_relic/utils'
import type { ToolConfig } from '@/tools/types'

interface GetEntityData {
actor?: {
entity?: {
name?: string | null
entityType?: string | null
} | null
entity?: NewRelicRawEntity | null
} | null
}

Expand Down Expand Up @@ -54,6 +53,15 @@ export const newRelicGetEntityTool: ToolConfig<NewRelicGetEntityParams, NewRelic
entity(guid: ${gqlString(params.guid.trim())}) {
name
entityType
domain
reporting
... on AlertableEntity {
alertSeverity
}
tags {
key
values
}
}
}
}`,
Expand All @@ -68,11 +76,7 @@ export const newRelicGetEntityTool: ToolConfig<NewRelicGetEntityParams, NewRelic
success: true,
output: {
entity: entity
? {
guid: params?.guid ?? null,
name: entity.name ?? null,
entityType: entity.entityType ?? null,
}
? { ...normalizeNewRelicEntity(entity), guid: params?.guid ?? null }
: null,
},
}
Expand All @@ -87,6 +91,28 @@ export const newRelicGetEntityTool: ToolConfig<NewRelicGetEntityParams, NewRelic
guid: { type: 'string', description: 'Entity GUID', nullable: true },
name: { type: 'string', description: 'Entity name', nullable: true },
entityType: { type: 'string', description: 'Entity type', nullable: true },
domain: { type: 'string', description: 'Entity domain, e.g. APM, INFRA', nullable: true },
reporting: {
type: 'boolean',
description: 'Whether the entity is currently reporting data',
nullable: true,
},
alertSeverity: {
type: 'string',
description: 'Current alert severity for the entity',
nullable: true,
},
tags: {
type: 'array',
description: 'Entity tags',
items: {
type: 'object',
properties: {
key: { type: 'string', description: 'Tag key', nullable: true },
values: { type: 'array', description: 'Tag values', items: { type: 'string' } },
},
},
},
},
},
},
Expand Down
38 changes: 35 additions & 3 deletions apps/sim/tools/new_relic/search_entities.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type {
NewRelicEntity,
NewRelicSearchEntitiesParams,
NewRelicSearchEntitiesResponse,
} from '@/tools/new_relic/types'
import {
getNerdGraphEndpoint,
type NewRelicRawEntity,
newRelicHeaders,
normalizeNewRelicEntity,
parseNerdGraphResponse,
} from '@/tools/new_relic/utils'
import type { ToolConfig } from '@/tools/types'
Expand All @@ -17,7 +18,7 @@ interface SearchEntitiesData {
query?: string
results?: {
nextCursor?: string | null
entities?: NewRelicEntity[]
entities?: NewRelicRawEntity[]
} | null
} | null
} | null
Expand Down Expand Up @@ -76,6 +77,15 @@ export const newRelicSearchEntitiesTool: ToolConfig<
guid
name
entityType
domain
reporting
... on AlertableEntityOutline {
alertSeverity
}
tags {
key
values
}
}
}
}
Expand All @@ -94,7 +104,7 @@ export const newRelicSearchEntitiesTool: ToolConfig<
if (!entitySearch) {
throw new Error('New Relic did not return entity search data')
}
const entities = entitySearch?.results?.entities ?? []
const entities = (entitySearch?.results?.entities ?? []).map(normalizeNewRelicEntity)

return {
success: true,
Expand All @@ -119,6 +129,28 @@ export const newRelicSearchEntitiesTool: ToolConfig<
guid: { type: 'string', description: 'Entity GUID', nullable: true },
name: { type: 'string', description: 'Entity name', nullable: true },
entityType: { type: 'string', description: 'Entity type', nullable: true },
domain: { type: 'string', description: 'Entity domain, e.g. APM, INFRA', nullable: true },
Comment thread
waleedlatif1 marked this conversation as resolved.
reporting: {
type: 'boolean',
description: 'Whether the entity is currently reporting data',
nullable: true,
},
alertSeverity: {
type: 'string',
description: 'Current alert severity for the entity',
nullable: true,
},
tags: {
type: 'array',
description: 'Entity tags',
items: {
type: 'object',
properties: {
key: { type: 'string', description: 'Tag key', nullable: true },
values: { type: 'array', description: 'Tag values', items: { type: 'string' } },
},
},
},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions apps/sim/tools/new_relic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ export interface NewRelicSearchEntitiesParams extends NewRelicBaseParams {
cursor?: string
}

export interface NewRelicEntityTag {
key: string | null
values: string[]
}

export interface NewRelicEntity {
guid: string | null
name: string | null
entityType: string | null
domain: string | null
reporting: boolean | null
alertSeverity: string | null
tags: NewRelicEntityTag[]
}

export interface NewRelicSearchEntitiesResponse extends ToolResponse {
Expand Down
26 changes: 25 additions & 1 deletion apps/sim/tools/new_relic/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import type { NewRelicRegion } from '@/tools/new_relic/types'
import type { NewRelicEntity, NewRelicRegion } from '@/tools/new_relic/types'

interface GraphQLError {
message?: string
}

export interface NewRelicRawEntity {
guid?: string | null
name?: string | null
entityType?: string | null
domain?: string | null
reporting?: boolean | null
alertSeverity?: string | null
tags?: ({ key?: string | null; values?: string[] | null } | null)[] | null
}

interface GraphQLResponse<TData> {
data?: TData
errors?: GraphQLError[]
Expand Down Expand Up @@ -40,3 +50,17 @@ export const cleanOptionalString = (value?: string): string | undefined => {
const trimmed = value?.trim()
return trimmed ? trimmed : undefined
}

export const normalizeNewRelicEntity = (entity: NewRelicRawEntity): NewRelicEntity => ({
guid: entity.guid ?? null,
name: entity.name ?? null,
entityType: entity.entityType ?? null,
domain: entity.domain ?? null,
reporting: entity.reporting ?? null,
alertSeverity: entity.alertSeverity ?? null,
tags:
entity.tags?.map((tag) => ({
key: tag?.key ?? null,
values: tag?.values ?? [],
})) ?? [],
})
Loading