Skip to content

Commit

Permalink
fixup: More promtail cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Mar 15, 2024
1 parent 37eacc6 commit 28c57bc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ jobs:
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
PROMTAIL_ID: ${{ secrets.PROMTAIL_ID }}
PROMTAIL_PASSWORD: ${{ secrets.PROMTAIL_PASSWORD }}
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
shell: bash
run: .github/workflows/notify-metrics-availability.sh
Expand Down Expand Up @@ -123,6 +123,12 @@ jobs:
env:
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
- name: Start promtail
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
shell: bash
run: .github/workflows/notify-metrics-availability.sh
Expand All @@ -147,6 +153,7 @@ jobs:
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
Upgrade:
runs-on: ubuntu-latest
Expand All @@ -165,6 +172,12 @@ jobs:
env:
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
- name: Start promtail
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
shell: bash
run: .github/workflows/notify-metrics-availability.sh
Expand All @@ -189,6 +202,7 @@ jobs:
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
Lint:
runs-on: ubuntu-latest
Expand Down
28 changes: 14 additions & 14 deletions scripts/run_promtail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
# running locally and in CI.
#
# The promtail instance will remain running in the background and will forward
# metrics to the central instance for all tmpnet networks.
# logs to the central instance for all tmpnet networks.
#
# To stop it:
#
Expand Down Expand Up @@ -36,15 +36,15 @@ if [[ -z "${LOKI_URL}" ]]; then
exit 1
fi

PROMTAIL_ID="${PROMTAIL_ID:-}"
if [[ -z "${PROMTAIL_ID}" ]]; then
echo "Please provide a value for PROMTAIL_ID"
LOKI_ID="${LOKI_ID:-}"
if [[ -z "${LOKI_ID}" ]]; then
echo "Please provide a value for LOKI_ID"
exit 1
fi

PROMTAIL_PASSWORD="${PROMTAIL_PASSWORD:-}"
if [[ -z "${PROMTAIL_PASSWORD}" ]]; then
echo "Plase provide a value for PROMTAIL_PASSWORD"
LOKI_PASSWORD="${LOKI_PASSWORD:-}"
if [[ -z "${LOKI_PASSWORD}" ]]; then
echo "Plase provide a value for LOKI_PASSWORD"
exit 1
fi

Expand Down Expand Up @@ -73,7 +73,7 @@ if ! command -v "${CMD}" &> /dev/null; then
PROMTAIL_FILE="promtail-${DIST}"
ZIP_PATH="/tmp/${PROMTAIL_FILE}.zip"
BIN_DIR="$(dirname "${CMD}")"
URL="https://github.com/grafana/loki/releases/download/VERSION/promtail-${DIST}.zip"
URL="https://github.com/grafana/loki/releases/download/${VERSION}/promtail-${DIST}.zip"
curl -L -o "${ZIP_PATH}" "${URL}"
unzip "${ZIP_PATH}" -d "${BIN_DIR}"
mv "${BIN_DIR}/${PROMTAIL_FILE}" "${CMD}"
Expand All @@ -91,16 +91,16 @@ server:
grpc_listen_port: 0
positions:
filename: "${PROMTAIL_WORKING_DIR}/positions.yaml
filename: "${PROMTAIL_WORKING_DIR}/positions.yaml"
client:
- url: "${LOKI_URL}/api/prom/push"
basic_auth:
username: "${LOKI_ID}"
password: "${LOKI_PASSWORD}"
url: "${LOKI_URL}/api/prom/push"
basic_auth:
username: "${LOKI_ID}"
password: "${LOKI_PASSWORD}"
scrape_configs:
- job_name: avalanchego
- job_name: "avalanchego"
file_sd_configs:
- files:
- '${FILE_SD_PATH}/*.json'
Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (n *Network) Start(ctx context.Context, w io.Writer) error {
if _, err := fmt.Fprintf(w, "\nStarted network %s (UUID: %s)\n", n.Dir, n.UUID); err != nil {
return err
}
// Provide a link the main dashboard filtered by the uuid and showing results for now till whenever the link is viewed
// Provide a link to the main dashboard filtered by the uuid and showing results from now till whenever the link is viewed
if _, err := fmt.Fprintf(w, "\nMetrics: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?&var-filter=network_uuid%%7C%%3D%%7C%s&var-filter=is_ephemeral_node%%7C%%3D%%7Cfalse&from=%d&to=now\n", n.UUID, startTime.UnixMilli()); err != nil {
return err
}
Expand Down Expand Up @@ -464,7 +464,7 @@ func (n *Network) Restart(ctx context.Context, w io.Writer) error {
func (n *Network) EnsureNodeConfig(node *Node) error {
flags := node.Flags

// Ensure nodes can write include the network uuid in their monitoring configuration
// Ensure nodes can label their metrics with the network uuid
node.NetworkUUID = n.UUID

// Ensure nodes can label metrics with an indication of the shared/private nature of the network
Expand Down Expand Up @@ -687,7 +687,7 @@ func (n *Network) getBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string,
return bootstrapIPs, bootstrapIDs, nil
}

// Retrieves the default path of the given network child dir.
// Retrieves the root dir for tmpnet data.
func getTmpnetPath() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
Expand Down

0 comments on commit 28c57bc

Please sign in to comment.