githubEdit

Setting Up InfluxDB and Grafana for k6 Load Testing

This guide explains how to deploy InfluxDB and Grafana in a Kubernetes environment and configure them to collect and visualize k6 load testing metrics . It includes deployment steps, secure configuration, and usage examples. Prerequisites Access to DuploPortal (Dev/Staging tenants) kubectl access to your Kubernetes cluster VPN access to view Grafana dashboards securely k6 installed on your local machine

  1. Deploy InfluxDB Step 1: Navigate to the Target Tenant Go to DuploPortal and select your tenant (Dev or Staging). Step 2: Create a Kubernetes Secret for Credentials apiVersion: v1 kind: Secret metadata: name: influxdb-secret type: Opaque stringData: admin-user: admin admin-password: YourStrongAdminPassword123! user: k6 user-password: YourStrongK6Password123! Apply it: kubectl apply -f influxdb-secret.yaml Step 3: Deploy InfluxDB StatefulSet with Persistent Volume Go to DuploPortal, Select the Tenant. Kubernetes ---> Services. Add Service. Provide service name and image influxdb:1.8 In Environment Variables section provide below details:

  • name: INFLUXDB_DB value: k6

  • name: INFLUXDB_HTTP_AUTH_ENABLED value: 'true'

  • name: INFLUXDB_ADMIN_USER value: admin

  • name: INFLUXDB_ADMIN_PASSWORD valueFrom: secretKeyRef: name: influxdb-secret key: admin-password

  • name: INFLUXDB_USER value: k6

  • name: INFLUXDB_USER_PASSWORD value: k6pass Click Update once all the details are filled correctly.

  1. Verify InfluxDB Setup curl http://:8086/ping Should return status 204 No Content. Check Databases curl -u admin:YourStrongAdminPassword123! "http://:8086/query?q=SHOW+DATABASES" You should see: {"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["k6"]]}]}]}

  2. Configure Grafana Access Grafana Go to DuploPortal Select Default Tenant Navigate to Cloud Services > Hosts Click on the Monitoring Host Choose container: system-svc-grafana-oc Open the container logs or configuration tab to find Grafana admin credentials Add InfluxDB as a Data Source Login to Grafana Navigate to Configuration > Data Sources Add InfluxDB URL : http://:8086 Access : Server Database : k6 User : admin Password : YourStrongAdminPassword123! HTTP > HTTP Method : GET Healthcheck Endpoint : /ping Name : InfluxDB-Dev or InfluxDB-Staging Click Save & Test

  3. Run k6 Tests and Send Data to InfluxDB Use the following command to run k6 tests and push results to InfluxDB: k6 run --out influxdb=http://k6:YourStrongK6Password123!@:8086/k6 your-test-file.js Note : Replace the InfluxDB URL and credentials accordingly.

  4. Visualize Test Results in Grafana Use the InfluxDB data source configured earlier Import or create dashboards based on the k6 metrics You can use community dashboards like this one: https://grafana.com/grafana/dashboards/2587-k6-load-testing-results

Last updated

Was this helpful?