SlapOS Home SlapOS

    How To Deploy Monitoring

    How to deploy monitoring
    • Last Update:2022-11-14
    • Version:003
    • Language:en

    Agenda

    • Prerequisite
    • Monitor Web Service
    • Deploy monitoring Web Service
    • Verification

    Being able to access the status of all the promises in your instance without the need to access Rapid.Space panel or the local SlapOS master is a necessity.

    This tutorial explains how to deploy the monitor web service inside the instances of your software release for remote monitoring.

    Here is the commit introducing this functionality to html5as Software release: commit diff.

    Prerequisites

    1. Read: Understanding SlapOS Promises
    2. Extend Monitor Stack
    3. Use Promises

    Monitor App

    Monitor app for a Service

    In the monitor app that uses the monitor webservices to aggregate data, you can see the history of failing services.

    Add new parameter: monitor-httpd-port

    Add a new parameter monitor-httpd-port in default-parameters of section [instance-html5as]. For backward compatibility the port default to 8197

    default-parameters =
      {
        "title": "Tutorial html5as",
        "download_url": "",
        "port": 8081,
        "monitor-httpd-port": 8197
      }
    

    Define Monitoring Portal

    In instance_html5as.cfg.in, overwrite the default listening port for your monitoring service. To do so, you need to add a [monitor-instance-parameter] section in the instance profile and use the key monitor-httpd-port for the port. You can refer to the monitor README to get the full list of keys that can be customized.

    # Use a port different from the default one in order to be able to
    # use it in a SlapOS webrunner or a Theia SlapOS Runner
    [monitor-instance-parameter]
    monitor-httpd-port = {{ parameter_dict['monitor-httpd-port'] }}
    

    Add dependency to Monitoring service

    Use a macro extension to include the content of the publish section of the monitor service in the [publish-connection-information] section of instance_html5as.cfg.in.

    [publish-connection-information]
    ...
    # By extending monitor publish, all the section deploying monitoring will
    # be deployed. The parameters needed for accessing monitoring will be published
    <= monitor-publish
    ...
    

    Update md5sums

    Refer How To Move to md5sum automatic update to update md5sum:

    $ cd ~/srv/project/slapos/software/html5as-base
    $ ../../update-hash

    Validation

    1. Verify Monitoring Parameters
    2. Connect to Monitor APP

    Verify Monitoring Parameters

    To inspect the output of slapos node software:

    $ slapos node software --all

    To inspect the output of slapos node instance:

    $ slapos node instance --all
    

    In the output of slapos node instance --all, it happens that you are having an error about Invalid URL: 

    slapos[41093] ERROR Promise 'monitor-http-frontend.py' failed with output: ERROR: Invalid URL '': No schema supplied. Perhaps you meant http://?

    OR

    TypeError: in constructor for ComputerPartition: computer_id and partition_id or request_dict are required

    It is because that the instance is requesting a RapidSpace CDN to display the monitor. You have to wait untill the error is no longer present, meaning you  have your instance instantiated successfully. You can get the correct monitor-setup-url as soon as the frontend for your monitoring is responded. Relaunch slapos node instance --all to verify if the instance is ready. 

    The parameters needed for accessing monitoring will be published. You can get the updated connection parameters by

    $ cd ~/srv/project/slapos/software/html5as-base/
    $ bash ../../../request-html5as-base.sh

    You can then connect to the monitor App with monitor-setup-url from the connection parameters.

    Connect to Monitor APP

    You can connect to the monitor App with monitor-setup-url from the connection parameters.