Search code examples
docker-composegrafanaoracle-cloud-infrastructure

Connect pyroscope to grafana datasource using .yaml config files and docker-compose


Status

  • Trying to integrate pyroscope to grafana using .yaml configuration file.
  • At local stage, it works well. But on cloud infrastructure, it does not work.

Configuration files

grafana-datasource.yaml

apiVersion: 1

datasources:
  - name: Pyroscope
    type: phlare
    basicAuth: false
    editable: true
    access: proxy
    uid: phlare
    url: http://pyroscope:4040
    version: 1
    jsonData:
        minStep: '15s'
        backendType: 'pyroscope'

pyroscope-local-config.yaml

storage-path: "/var/lib/pyroscope"

retention: 360h # 15 days
exemplars-retention: 72h # 3 days

scrape-configs:
  job-name: pyroscope
  scrape-interval: 10s
  enabled-profiles: [cpu, mem]

docker-compose.yaml

version: "3.9"

services:
  grafana:
    image: grafana/grafana:latest
    hostname: "grafana"
    container_name: "grafana"
    ports:
      - "3000:3000"
    volumes:
      - ./grafana/grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
    networks:
      - pyroscope

  pyroscope:
    hostname: pyroscope
    container_name: pyroscope
    image: "pyroscope/pyroscope:latest"
    deploy:
      restart_policy:
        condition: on-failure
    ports:
      - "4040:4040"
    command:
      - "server"
    volumes:
      - ./grafana/pyroscope-local-config.yaml:/etc/pyroscope/server.yaml
    networks:
      - pyroscope

networks:
  pyroscope:
    name: pyroscope
    driver: bridge

Network configuration in cloud infrastructure

enter image description here


What I did for resolving this issue?

reading documentary related grafana and pyroscope

  • I read but still I don't know what is the root cause

allowing all traffic from TCP in cloud infrastructure console

  • didn't work

changed configuration files

  • didn't work too

What I want to do

Integrate the pyroscope into grafana like this

grafana on local stage Well-integrated grafana with pyroscope datasource at local grafana on cloud infrastructure But it does not integrated when I deploy on cloud infrastructure

Error logs

logger=accesscontrol.evaluator t=2023-08-25T00:27:12.67422445Z level=debug msg="matched scope" userscope=datasources:* targetscope=datasources:uid:phlare
logger=datasources t=2023-08-25T00:27:12.67432201Z level=debug msg="Received command to update data source" url=http://pyroscope:4040
logger=datasource t=2023-08-25T00:27:12.67433261Z level=debug msg="Applying default URL parsing for this data source type" type=phlare url=http://pyroscope:4040
logger=sqlstore.session t=2023-08-25T00:27:12.67461233Z level=debug msg="reusing existing session" transaction=true
logger=secrets.kvstore t=2023-08-25T00:27:12.67481805Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=Pyroscope
logger=sqlstore.session t=2023-08-25T00:27:12.67483685Z level=debug msg="reusing existing session" transaction=true
logger=sqlstore.session t=2023-08-25T00:27:12.675196969Z level=debug msg="reusing existing session" transaction=true
logger=sqlstore.session t=2023-08-25T00:27:12.680797361Z level=debug msg="reusing existing session" transaction=true
logger=secrets.kvstore t=2023-08-25T00:27:12.68130112Z level=debug msg="secret value updated" orgId=1 type=datasource namespace=Pyroscope
logger=sqlstore.transactions t=2023-08-25T00:27:12.68132252Z level=debug msg="skip committing the transaction because it belongs to a session created in the outer scope"
logger=sqlstore.transactions t=2023-08-25T00:27:12.6813886Z level=debug msg="skip committing the transaction because it belongs to a session created in the outer scope"
logger=secrets.kvstore t=2023-08-25T00:27:12.687266791Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=Pyroscope
logger=accesscontrol.evaluator t=2023-08-25T00:27:12.729860369Z level=debug msg="matched scope" userscope=datasources:* targetscope=datasources:uid:phlare
logger=secrets.kvstore t=2023-08-25T00:27:12.730420729Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=Pyroscope
logger=datasources t=2023-08-25T00:27:12.75003998Z level=debug msg="Querying for data source via SQL store" uid=phlare orgId=1
logger=secrets.kvstore t=2023-08-25T00:27:12.75029442Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=Pyroscope
logger=tsdb.phlare t=2023-08-25T00:27:12.750416739Z level=debug msg="CheckHealth called"
logger=context userId=0 orgId=1 uname= t=2023-08-25T00:27:12.752653816Z level=info msg="Request Completed" method=GET path=/api/datasources/uid/phlare/health status=400 remote_addr={local-machine-addr} time_ms=3 duration=3.089555ms size=59 referer=http://{my-cloud-infra-ip-addr}:3000/connections/your-connections/datasources/edit/phlare handler=/api/datasources/uid/:uid/health
logger=ngalert.scheduler t=2023-08-25T00:27:20.000481563Z level=debug msg="Alert rules fetched" rulesCount=0 foldersCount=0 updatedRules=0

It is the logs when I send a healthcheck via grafana web dashboard.


Solution

  • TL;DR

    • Check the versions of images before.
    • I used docker compose pull command to get the latest image versions, so this issue is resolved

    Thanks to @JanGaraj, and @MT0