@@ -1,34 +1,29 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { esClient, INDEX_NAME } from '@/lib/elasticsearch';
|
||||
import { getRedisInfo, getStats, INDEX_NAME } from '@/lib/redis';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Check Elasticsearch connection
|
||||
const health = await esClient.cluster.health({});
|
||||
// Check Redis connection and get info
|
||||
const redisInfo = await getRedisInfo();
|
||||
|
||||
// Check if index exists
|
||||
const indexExists = await esClient.indices.exists({ index: INDEX_NAME });
|
||||
|
||||
// Get index stats if exists
|
||||
let stats = null;
|
||||
if (indexExists) {
|
||||
const statsResponse = await esClient.indices.stats({ index: INDEX_NAME });
|
||||
stats = {
|
||||
documentCount: statsResponse._all?.primaries?.docs?.count || 0,
|
||||
indexSize: statsResponse._all?.primaries?.store?.size_in_bytes || 0
|
||||
};
|
||||
}
|
||||
// Get index stats
|
||||
const stats = await getStats();
|
||||
|
||||
return NextResponse.json({
|
||||
status: 'ok',
|
||||
elasticsearch: {
|
||||
cluster: health.cluster_name,
|
||||
status: health.status,
|
||||
redis: {
|
||||
connected: redisInfo.connected,
|
||||
version: redisInfo.version,
|
||||
usedMemory: redisInfo.usedMemory,
|
||||
dbSize: redisInfo.dbSize
|
||||
},
|
||||
index: {
|
||||
exists: indexExists,
|
||||
exists: true,
|
||||
name: INDEX_NAME,
|
||||
stats
|
||||
stats: {
|
||||
documentCount: stats.count,
|
||||
indexSize: stats.size
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Referencia en una nueva incidencia
Block a user