github.com/grafana/synthetic-monitoring-agent@v0.64.2/scripts/README.md (about)

     1  ### Local environment tools
     2  Follow the steps below to work with a local Synthetic Monitoring kubernetes cluster, and add a development version of the SM agent in there.
     3  
     4  First, install the `Synthetic Monitoring plugin` in a `Grafana` instance, and follow these instructions on how to add a `Probe`.
     5  1. Go into the SM Plugin.
     6  2. First go to `Config`. You will notice under `Backend Address` a URL. This is the Synthetic Monitoring API URL. Save that for later, we will call it `<sm api url>`.
     7  4. After that, click`Probes`. Then `New`.
     8  5. Configure a `Probe Name`, and a `Region` name (`amer` for example). Click `Save`.
     9  6. Copy the `Probe Authentication Token`, and the `<sm api url>` (which if not present will default to `sm-api:4031`) in a config file with the following format:
    10  ```
    11  API_TOKEN=<probe authentication code>
    12  SM_API_URL=<sm api url> 
    13  ```
    14  5. Save the file and let's call its path `<config file path>`.
    15  6. Deploy and build the agent into the local cluster by running:
    16  ```bash
    17  ./scripts/sm-dev <config file path>
    18  ```
    19  
    20  In the case you just want to deploy a k8s configuration change to the local cluster, run:
    21  ```bash
    22  ./scripts/sm-dev -n <config file path>
    23  ```
    24  This will avoid re-building the SM agent Docker image.
    25  
    26  Once , the agent will be reachable in the following host endpoint: `http://sm-agent.k3d.localhost:9999`. If you find
    27  a `Could not resolve host` error, follow the steps in the [troubleshooting](#troubleshooting) section.
    28  
    29  ### Troubleshooting
    30  
    31  #### Curling cluster ingress URLS gives you `curl: (6) Could not resolve host`
    32  
    33  There appears to be a DNS issue introduced by Big Sur where `*.localhost` top level domains do not resolve by default. Browsers will likely still resolve the URLs but curl and other CLI apps will not. Known fixes for this issue are below,
    34  
    35  1. Add all services to your /etc/hosts file (really annoying because there are quite a few services if you install apps)
    36  2. Setup a local DNS server to route `*.localhost` -> `127.0.0.1`
    37      - The commands below will setup the rule using dnsmasq (Adopted from this gist https://gist.github.com/ogrrd/5831371)
    38     ```shell
    39     brew install dnsmasq
    40  
    41     mkdir -pv $(brew --prefix)/etc/
    42  
    43     echo 'address=/.localhost/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
    44  
    45     sudo brew services start dnsmasq
    46  
    47     sudo mkdir -v /etc/resolver
    48  
    49     sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/localhost'
    50  
    51     scutil --dns #should now show the localhost resolver
    52     ```
    53      - Retry the curl commands for integrations-api/hosted-exporters and you should hopefully get results now