// src/app/api/datadog-dashboard/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  const { DATADOG_API_KEY } = process.env;
  const dashboardId = '8y9-dxj-2mr'; // Replace with your actual dashboard ID

  if (!DATADOG_API_KEY) {
    return NextResponse.json({ error: 'Datadog API key is missing' }, { status: 400 });
  }
  console.log('DATADOG_API_KEY', DATADOG_API_KEY);

  const response = await fetch(`https://api.datadoghq.com/api/v1/dashboard/${dashboardId}`, {
    headers: {
      'Content-Type': 'application/json',
      'DD-API-KEY': 'c71d8193e63c900e237e62cd58fc0b3e',
      'DD-APPLICATION-KEY': 'a58a28fd8ef312c2d67ef8cf1cfeb3a880320f3a',
      // 'DD-API-KEY': 'a58a28fd8ef312c2d67ef8cf1cfeb3a880320f3a',
    },
  });

  if (!response.ok) {
    return NextResponse.json({ error: 'Failed to fetch dashboard data' }, { status: response.status });
  }

  const data = await response.json();
  return NextResponse.json(data);
}
