d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
112 lines
2.8 KiB
TypeScript
112 lines
2.8 KiB
TypeScript
import type { NewRelicNrqlQueryParams, NewRelicNrqlQueryResponse } from '@/tools/new_relic/types'
|
|
import {
|
|
getNerdGraphEndpoint,
|
|
gqlString,
|
|
newRelicHeaders,
|
|
parseNerdGraphResponse,
|
|
} from '@/tools/new_relic/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
interface NrqlQueryData {
|
|
actor?: {
|
|
account?: {
|
|
nrql?: {
|
|
results?: Record<string, unknown>[]
|
|
} | null
|
|
} | null
|
|
} | null
|
|
}
|
|
|
|
export const newRelicNrqlQueryTool: ToolConfig<NewRelicNrqlQueryParams, NewRelicNrqlQueryResponse> =
|
|
{
|
|
id: 'new_relic_nrql_query',
|
|
name: 'New Relic NRQL Query',
|
|
description: 'Run a NRQL query against a New Relic account using NerdGraph.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'New Relic user API key for NerdGraph',
|
|
},
|
|
region: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'New Relic data center region: us or eu',
|
|
},
|
|
accountId: {
|
|
type: 'number',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'New Relic account ID to query',
|
|
},
|
|
nrql: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'NRQL query to execute',
|
|
},
|
|
timeout: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Optional query timeout in seconds',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => getNerdGraphEndpoint(params.region),
|
|
method: 'POST',
|
|
headers: (params) => newRelicHeaders(params.apiKey),
|
|
body: (params) => {
|
|
const timeout = params.timeout ? `, timeout: ${Math.trunc(Number(params.timeout))}` : ''
|
|
return {
|
|
query: `{
|
|
actor {
|
|
account(id: ${Math.trunc(Number(params.accountId))}) {
|
|
nrql(query: ${gqlString(params.nrql)}${timeout}) {
|
|
results
|
|
}
|
|
}
|
|
}
|
|
}`,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response) => {
|
|
const payload = await parseNerdGraphResponse<NrqlQueryData>(response)
|
|
const nrql = payload.data?.actor?.account?.nrql
|
|
if (!nrql) {
|
|
throw new Error('New Relic did not return NRQL data for the requested account')
|
|
}
|
|
const results = nrql.results ?? []
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
results,
|
|
resultCount: results.length,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
results: {
|
|
type: 'array',
|
|
description: 'NRQL result rows. Row fields depend on the query projection.',
|
|
items: {
|
|
type: 'object',
|
|
description: 'A NRQL result row',
|
|
},
|
|
},
|
|
resultCount: {
|
|
type: 'number',
|
|
description: 'Number of NRQL result rows returned',
|
|
},
|
|
},
|
|
}
|