Building Grafana - linux-on-ibm-z/docs GitHub Wiki

Building Grafana

Below versions of Grafana are available in respective distributions at the time of creation of these build instructions:

  • RHEL (8.6, 8.8, 8.9, 9.0, 9.2, 9.3) have 9.2.10
  • SLES 15 SP5 has 9.5.8

The instructions provided below specify the steps to build Grafana 10.3.3 on Linux on IBM Z for following distributions:

  • RHEL (8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
  • SLES 15 SP5
  • Ubuntu (20.04, 22.04, 23.10)

General Note:

  • When following the steps below please use a standard permission user unless otherwise specified
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Build and Install Grafana

Step 1: Build using script

If you want to build Grafana using manual steps, go to STEP 2.

Use the following commands to build Grafana using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Grafana/10.3.3/build_grafana.sh

# Build Grafana
bash build_grafana.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 4. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install the dependencies

export SOURCE_ROOT=/<source_root>/
export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Grafana/10.2.2/patch"
  • RHEL (8.6, 8.8, 8.9)

    sudo yum install -y make gcc gcc-c++ tar wget git git-core patch xz curl python3
  • RHEL (9.0, 9.2, 9.3)

    sudo yum install -y --allowerasing make gcc gcc-c++ tar wget git git-core patch xz curl python3
  • SLES 15 SP5

    sudo zypper install -y make gcc gcc-c++ wget tar git-core xz gzip curl patch python3 libnghttp2-devel
  • Ubuntu (20.04, 22.04, 23.10)

    sudo apt-get update
    sudo apt-get install -y gcc g++ tar wget git make xz-utils patch curl python3
  • Install GO v1.21.4

    wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Go/1.18.4/build_go.sh
    bash build_go.sh -y -v 1.21.4
    go version
  • Install Nodejs

    cd $SOURCE_ROOT
    source "/etc/os-release"
    DISTRO="$ID-$VERSION_ID"
    NODE_JS_VERSION=20.11.1
    wget https://nodejs.org/dist/v${NODE_JS_VERSION}/node-v${NODE_JS_VERSION}-linux-s390x.tar.xz
    chmod ugo+r node-v${NODE_JS_VERSION}-linux-s390x.tar.xz
    sudo tar -C /usr/local -xf node-v${NODE_JS_VERSION}-linux-s390x.tar.xz
    export PATH=$PATH:/usr/local/node-v${NODE_JS_VERSION}-linux-s390x/bin
    node -v
  • Install Yarn

    cd $SOURCE_ROOT
    sudo chmod ugo+w -R /usr/local/node-v20.11.1-linux-s390x     
    npm install -g yarn
    yarn set version 4.1.0
    yarn --version

Step 3: Build Grafana

  • Download Grafana

    export GOPATH=$SOURCE_ROOT
    cd $GOPATH
    git clone https://github.com/grafana/grafana.git
    cd grafana
    git checkout v10.3.3
    sed -i '/yarnPath/d' .yarnrc.yml
  • Build Grafana Frontend

    cd $GOPATH/grafana
    yarn install
    mkdir plugins-bundled/external
    export NODE_OPTIONS="--max-old-space-size=8192"
    make build-js
  • Build Grafana Backend

    cd $GOPATH/grafana
    make gen-go
    make deps-go
    make build-go
  • Copy Grafana binaries to /usr/bin

    sudo cp $GOPATH/grafana/bin/linux-s390x/grafana /usr/bin/
    sudo cp $GOPATH/grafana/bin/linux-s390x/grafana-server /usr/bin/
    sudo cp $GOPATH/grafana/bin/linux-s390x/grafana-cli /usr/bin/

Step 4: Start Grafana server

  • Start Grafana server
    grafana server --homepath=<path_to_installed_home_dir_of_grafana>

Note:

  • After starting Grafana server, you can view the Grafana console at http://<HOST_IP>:<PORT>/.

  • Custom configuration file is located at $GOPATH/grafana/conf/defaults.ini & custom configuration file path can be overridden using the --config parameter.

  • Plugin grafana-image-renderer is not supported on s390x as it uses headless chromium browser which is not supported on s390x

Step 5: Testing (Optional)

  • Run backend tests

    make test-go
  • Run frontend tests

    cd $GOPATH/grafana
    yarn test --watchAll=false

Note:

  • The following error may occur: "Error: ENOSPC: System limit for number of file watchers reached". If it does, you'll need to increase the number of max user watches for inotify. Append or change to a new max in the /etc/sysctl.conf file.

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    
    # This will check if the value has been changed.
    cat /proc/sys/fs/inotify/max_user_watches

Reference

⚠️ **GitHub.com Fallback** ⚠️