Skip to Content
Back to Blog

Kibana Dashboards for ft_transcendence: Visualizing Project Data

Kibana Dashboards for ft_transcendence: Visualizing Project Data

Why Dashboards Matter

Dashboards are crucial for transforming raw log data into actionable insights. For our ft_transcendence project, well-designed Kibana dashboards help us:

  1. Monitor System Health: Quickly spot issues with any service
  2. Track User Experience: Understand how users interact with the application
  3. Identify Security Concerns: Detect unusual patterns or potential threats
  4. Optimize Performance: Pinpoint bottlenecks and inefficiencies

Dashboard Structure for ft_transcendence

We've organized our dashboards into three main categories:

1. Operations Dashboards

  • System Overview: High-level health of all services
  • Service-Specific: Detailed metrics for each service
  • Error Tracking: Aggregated view of all errors

2. User Experience Dashboards

  • API Performance: Response times and error rates
  • User Sessions: Login patterns and session durations
  • Feature Usage: Which parts of the app users engage with most

3. Security Dashboards

  • Authentication Events: Logins, logouts, and failures
  • Access Patterns: Unusual activity detection
  • Error Clustering: Finding patterns in security-related errors

Creating Our Main Dashboard

Here's how we built our System Overview dashboard:

Step 1: Index Pattern Configuration

First, we created index patterns to access our data:

  1. In Kibana, go to Stack Management > Index Patterns
  2. Create patterns for each service:
    • django-*
    • nginx-*
    • nextjs-*
    • postgresql-*
    • redis-*

Step 2: Building Visualizations

We created these key visualizations:

Service Health Status

{
  "aggs": {
    "services": {
      "terms": {
        "field": "service.keyword",
        "size": 10
      },
      "aggs": {
        "errors": {
          "filter": {
            "bool": {
              "should": [
                { "term": { "log_level.keyword": "ERROR" } },
                { "term": { "log_level.keyword": "CRITICAL" } },
                { "range": { "http_status": { "gte": 500 } } }
              ]
            }
          }
        },
        "health": {
          "bucket_script": {
            "buckets_path": {
              "errors": "errors._count"
            },
            "script": "params.errors > 0 ? 'error' : 'healthy'"
          }
        }
      }
    }
  }
}

Request Volume Over Time

{
  "aggs": {
    "requests_over_time": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "30s"
      },
      "aggs": {
        "by_service": {
          "terms": {
            "field": "service.keyword",
            "size": 5
          }
        }
      }
    }
  }
}

Error Distribution Pie Chart

{
  "aggs": {
    "error_types": {
      "terms": {
        "field": "error_type.keyword",
        "size": 10
      }
    }
  },
  "query": {
    "bool": {
      "must": [{ "term": { "log_level.keyword": "ERROR" } }]
    }
  }
}

Step 3: Assembling the Dashboard

We arranged visualizations in a logical flow:

  1. Top Section: Status indicators showing at-a-glance health
  2. Middle Section: Time-series graphs showing activity trends
  3. Bottom Section: Detailed tables for drilling down into specific issues

Service-Specific Dashboards

Django Dashboard Example

For our Django application, we focused on:

  1. View Performance: Response times by view function
  2. Database Queries: Query execution times and counts
  3. Error Traceback: Full error details with context

Key visualization for slow database queries:

{
  "aggs": {
    "over_time": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "1m"
      },
      "aggs": {
        "slow_queries": {
          "filter": {
            "bool": {
              "must": [
                { "exists": { "field": "query_time" } },
                { "range": { "query_time": { "gte": 100 } } }
              ]
            }
          }
        }
      }
    }
  }
}

Nginx Dashboard Example

For Nginx monitoring, we focus on:

  1. Request Rate: Requests per second
  2. Status Codes: Distribution of HTTP response codes
  3. Response Times: Latency percentiles
  4. Top URLs: Most frequently accessed endpoints
  5. Client IPs: Source of requests by geography

User Activity Dashboard

This dashboard helps us understand user behavior:

  1. Session Flow Visualization: Shows how users navigate through the app
  2. User Retention: How often users return to the app
  3. Feature Adoption: Which features are used most

Example visualization for session duration:

{
  "aggs": {
    "users": {
      "terms": {
        "field": "user_id.keyword",
        "size": 100
      },
      "aggs": {
        "session_start": {
          "min": {
            "field": "@timestamp"
          }
        },
        "session_end": {
          "max": {
            "field": "@timestamp"
          }
        },
        "session_duration": {
          "bucket_script": {
            "buckets_path": {
              "start": "session_start",
              "end": "session_end"
            },
            "script": "(params.end - params.start) / 60000"
          }
        }
      }
    }
  }
}

Security Monitoring Dashboard

Our security dashboard focuses on:

  1. Authentication Events: Success/failure tracking
  2. Geographic Anomalies: Unusual access locations
  3. Rate Limiting Violations: Potential brute force attacks
  4. Permission Denials: Unauthorized access attempts

Example visualization for failed login attempts:

{
  "aggs": {
    "over_time": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "5m"
      },
      "aggs": {
        "by_ip": {
          "terms": {
            "field": "client_ip.keyword",
            "size": 10
          }
        }
      }
    }
  },
  "query": {
    "bool": {
      "must": [{ "term": { "event.keyword": "login_failed" } }]
    }
  }
}

Setting Up Alerts

We've configured alerts to notify us of critical issues:

Error Rate Alert

{
  "trigger": {
    "schedule": {
      "interval": "5m"
    }
  },
  "input": {
    "search": {
      "indices": ["*"],
      "body": {
        "query": {
          "bool": {
            "must": [
              { "range": { "@timestamp": { "gte": "now-5m" } } },
              { "terms": { "log_level.keyword": ["ERROR", "CRITICAL"] } }
            ]
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 10
      }
    }
  },
  "actions": {
    "notify_team": {
      "webhook": {
        "url": "https://hooks.slack.com/services/YOUR_WEBHOOK",
        "body": "Error rate exceeded threshold: {{ctx.payload.hits.total}} errors in the last 5 minutes"
      }
    }
  }
}

Performance Considerations

Since we're running in a limited environment, we've optimized our dashboards:

  1. Time Range Control: Default to shorter time ranges (last 15 minutes)
  2. Reduced Refresh Rate: Default to manual refresh or 1-minute intervals
  3. Aggregation Over Raw Data: Use aggregations instead of raw document tables
  4. Limited Cardinality: Avoid visualizations with high cardinality fields

Sharing Dashboards

To make dashboards accessible to team members:

  1. Export/Import: Share dashboard JSON definitions
  2. Saved Object Management: Export and import through Kibana UI
  3. Version Control: Store dashboard definitions in Git

Dashboard Templates

We've created templates for quick setup of new dashboards:

{
  "attributes": {
    "title": "Service Dashboard Template",
    "hits": 0,
    "description": "Template for monitoring any service",
    "panelsJSON": "[{\"id\":\"request-rate\",\"type\":\"visualization\",\"panelIndex\":1,\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":8},\"version\":\"7.10.0\"},{\"id\":\"error-rate\",\"type\":\"visualization\",\"panelIndex\":2,\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":8},\"version\":\"7.10.0\"},{\"id\":\"response-time\",\"type\":\"visualization\",\"panelIndex\":3,\"gridData\":{\"x\":0,\"y\":8,\"w\":48,\"h\":8},\"version\":\"7.10.0\"}]"
  }
}

Conclusion

Well-designed Kibana dashboards transform our raw log data into valuable insights for ft_transcendence. By taking the time to create effective visualizations and dashboards, we gain:

  1. Better understanding of system behavior
  2. Faster troubleshooting of issues
  3. Deeper insights into user activity
  4. Improved security monitoring

In our resource-constrained environment, these dashboards help us maximize the value of our observability data without requiring excessive resources.