Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GenAI Ops Manager

A comprehensive Dynatrace App for monitoring, analyzing, and optimizing Generative AI workloads. Built with React, TypeScript, and the Dynatrace SDK, this app provides real-time visibility into GenAI usage, costs, and performance using Grail data.

Dynatrace React TypeScript

🎯 Features

πŸ“Š Home Dashboard

  • Real-time GenAI metrics: Total requests, tokens, cost estimates, and unique models
  • Top models by usage: Quick overview of most-used AI models
  • Navigation cards: Quick access to all analytics pages

πŸ’° Cost Forecast & FinOps

  • Historical cost trends: 30-day visualization of token usage and estimated costs
  • Weekly growth rate: Automatic calculation of usage growth trends
  • Budget alerts: Set budget limits and get warnings when projected costs exceed thresholds
  • Cost by model breakdown: See which models are driving costs
  • Optimization suggestions: AI-powered recommendations for cost reduction

πŸ“ˆ Model Cost Comparison

  • Side-by-side model analysis: Compare costs, performance, and usage across different AI models
  • Cost per 1K tokens: Standardized pricing comparison
  • Performance metrics: Latency, error rates, and token efficiency
  • Migration recommendations: Identify opportunities to switch to cheaper alternatives

πŸ” Prompt Pattern Analyzer

  • Security Detection: AI-powered analysis for PII, prompt injection, and sensitive data
    • πŸ” PII Detection: SSN, emails, phone numbers, credit cards, DOB, medical records (HIPAA/PHI)
    • ⚠️ Injection Attempts: Jailbreak patterns, instruction override, role-playing attacks
    • πŸ”’ Sensitive Data: Passwords, API keys, tokens, internal company data
    • βš–οΈ Bias Risk: Protected characteristics in HR/hiring/decision contexts
    • 🎭 Hallucination Risk: Real-time data queries without grounding or factual verification
    • πŸ’° Cost Analysis: High token/cost pattern identification
    • πŸ”„ Cache Opportunities: Repetitive patterns eligible for semantic caching (15+ occurrences)
  • Compliance & Governance: Comprehensive security scoring and risk assessment
  • Actionable Insights: AI-generated recommendations for remediation
  • Filter & Search: Quickly find problematic patterns by issue type
  • Token efficiency analysis: Input/output ratio and average token usage
  • Optimization recommendations: Suggestions for prompt engineering improvements

πŸ”§ Agent Tool Heatmap

  • Tool usage visualization: Heatmap of AI agent tool calls
  • Agent flow analysis: Understand which tools are called together
  • Loop detection: Identify potential infinite loops in agent workflows
  • Error rate tracking: Monitor tool reliability

⚑ Guardrail Backtester

  • Policy simulation: Test guardrail policies against historical data
  • Violation detection: Identify requests that would be blocked
  • Impact analysis: Understand the effect of policies before deployment
  • Custom threshold testing: Experiment with different limits

πŸ’Ή Model Arbitrage Simulator

  • Cost optimization scenarios: Simulate routing strategies across models
  • Performance trade-off analysis: Balance cost vs quality
  • Savings projections: Estimate potential cost reductions
  • Model routing recommendations: Optimize model selection

πŸ—οΈ Architecture

genai-ops-manager/
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ main.tsx              # App entry point
β”‚   └── app/
β”‚       β”œβ”€β”€ App.tsx           # Main app with routing
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ Card.tsx      # Reusable card component
β”‚       β”‚   └── Header.tsx    # App header
β”‚       └── pages/
β”‚           β”œβ”€β”€ Home.tsx                    # Dashboard
β”‚           β”œβ”€β”€ CostForecast.tsx            # FinOps analytics
β”‚           β”œβ”€β”€ ModelCostComparison.tsx     # Model comparison
β”‚           β”œβ”€β”€ PromptAnalyzer.tsx          # Prompt analysis
β”‚           β”œβ”€β”€ AgentToolHeatmap.tsx        # Agent tools
β”‚           β”œβ”€β”€ GuardrailBacktester.tsx     # Policy testing
β”‚           └── ModelArbitrageSimulator.tsx # Cost optimization
β”œβ”€β”€ app.config.json           # Dynatrace app configuration
β”œβ”€β”€ package.json              # Dependencies and scripts
└── vitest.config.ts          # Test configuration

πŸ“‹ Prerequisites

  • Node.js 16.13.0 or higher (Node.js 22 recommended)
  • Dynatrace environment with GenAI observability data
  • Required OAuth scopes:
    • storage:spans:read - For GenAI trace data
    • storage:logs:read - For log analysis
    • storage:buckets:read - For Grail bucket access
    • storage:events:read - For event data
    • storage:metrics:read - For metric data

πŸš€ Getting Started

Installation

# Clone the repository
git clone https://github.com/pushpendrasinghbaghel-ai/genai-ops-manager.git
cd genai-ops-manager

# Install dependencies
npm install

Development

# Start development server
npm run start

# Or specify environment URL
npx dt-app dev --environment-url https://your-tenant.apps.dynatrace.com --open

Build & Deploy

# Build for production
npm run build

# Deploy to Dynatrace
npm run deploy

Testing

# Run tests
npm run test

# Run tests once
npm run test:run

# Run with coverage
npm run test:coverage

πŸ“Š DQL Queries

The app uses Dynatrace Query Language (DQL) to fetch GenAI observability data from Grail. Key query patterns:

GenAI Spans Filter

fetch spans, from: now()-24h
| filter isNotNull(gen_ai.provider.name) OR isNotNull(gen_ai.request.model)

Token Usage Aggregation

| summarize 
    total_input = sum(coalesce(gen_ai.usage.input_tokens, gen_ai.usage.prompt_tokens, 0)),
    total_output = sum(coalesce(gen_ai.usage.output_tokens, gen_ai.usage.completion_tokens, 0))

Tool Usage (Agent Spans)

fetch spans, from: now()-24h
| filter traceloop.span.kind == "tool"
| summarize call_count = count(), by: { tool_name = span.name }

Prompt Analysis with Security Detection

fetch spans, from: now()-24h
| filter isNotNull(gen_ai.provider.name) OR isNotNull(gen_ai.request.model)
| fieldsAdd prompt = coalesce(gen_ai.prompt.1.content, gen_ai.prompt.0.content)
| filter isNotNull(prompt)
| fieldsAdd prompt_preview = substring(prompt, from:0, to:200)
| summarize 
    count = count(),
    avg_input_tokens = avg(coalesce(gen_ai.usage.input_tokens, 0)),
    avg_output_tokens = avg(coalesce(gen_ai.usage.output_tokens, 0)),
    by: { prompt_preview, model = gen_ai.request.model, provider = gen_ai.provider.name }
| sort count desc

πŸ”’ Security Features

The Prompt Analyzer includes comprehensive security detection patterns:

Detection Type Description Severity Levels
πŸ” PII SSN, email, phone, credit cards, DOB, medical records (HIPAA/PHI) Critical, High, Medium
⚠️ Injection Jailbreak attempts, instruction override, role-playing attacks Critical
πŸ”’ Sensitive Passwords, API keys, tokens, internal company data High
βš–οΈ Bias Protected characteristics in HR/hiring/decision contexts High
🎭 Hallucination Real-time data queries without grounding/verification Medium, Low
πŸ’° Cost High token/cost patterns requiring optimization Critical to Low
πŸ”„ Repetitive Patterns repeated 15+ times (cache candidates) Low

Example Use Cases:

  • Compliance: Detect HIPAA/PHI violations before data reaches LLMs
  • Security: Identify prompt injection and jailbreak attempts
  • Cost Optimization: Find expensive patterns and cache opportunities
  • Bias Prevention: Flag protected characteristics in decision-making prompts
  • Quality: Detect hallucination risks from real-time data queries

πŸ§ͺ Test Coverage

The app includes comprehensive unit tests:

  • DQL Query Validation: Tests for correct query syntax and patterns
  • Cost Estimation: Tests for pricing calculations across models
  • App Configuration: Tests for required OAuth scopes
npm run test:run

# Output:
# βœ“ ui/app/tests/dql-queries.test.ts (15 tests)
# βœ“ ui/app/tests/app-config.test.ts (9 tests)
# βœ“ ui/app/tests/cost-estimation.test.ts (21 tests)
# Test Files: 3 passed (3)
# Tests: 45 passed (45)

πŸ“ Available Scripts

Script Description
npm run start Start development server
npm run build Build for production
npm run deploy Deploy to Dynatrace
npm run uninstall Uninstall from Dynatrace
npm run test Run tests in watch mode
npm run test:run Run tests once
npm run test:coverage Run tests with coverage
npm run lint Run ESLint

πŸ”§ Configuration

app.config.json

{
  "environmentUrl": "https://your-tenant.apps.dynatrace.com/",
  "app": {
    "name": "GenAI Ops Manager",
    "version": "0.0.1",
    "description": "Monitor and optimize GenAI workloads",
    "id": "my.genai.ops.manager",
    "scopes": [
      { "name": "storage:spans:read" },
      { "name": "storage:logs:read" },
      { "name": "storage:buckets:read" },
      { "name": "storage:events:read" },
      { "name": "storage:metrics:read" }
    ]
  }
}

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“š Learn More

πŸ“„ License

This project is licensed under the ISC License.


Built with ❀️ for the Dynatrace Platform

About

GenAI Ops Manager - Dynatrace App for monitoring and optimizing GenAI workloads

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages