release-argus / Argus

Argus is a lightweight monitor to notify of new software releases via Gotify/Slack/other messages and/or WebHooks.
https://release-argus.io
Apache License 2.0
291 stars 11 forks source link

Gotify Configuration #55

Closed samcro1967 closed 2 years ago

samcro1967 commented 2 years ago

@JosephKav I was going to wait until Shoutrr integration is implemented, but thought I would give Gotify a spin. I am not getting notifications. Am I missing something?

Global Block

settings:
  web:
    listen_host: 0.0.0.0
    listen_port: "8111"
    route_prefix: /
defaults:
  service:
    access_token: <redacted>
    interval: 30m
    deployed_version: {}
gotify:
  GOTIFY_NOTIFICATION:
    url: http://osu.gotify:8132
    token: <redacted>
    title: Argus Notification
    message: {{ service_id }} - {{ version }} released.
    extras:
      client_display: text/plain
      client_notification: '{{ web_url }}'
    priority: 5
    delay: 0s
    max_tries: 3

Service Definition

Service:
  CaddyDockerProxy:
    type: url
    url: https://github.com/lucaslorentz/caddy-docker-proxy/tags
    semantic_versioning: false
    url_commands:
      - type: regex
        regex: releases\/tag\/(v[0-9.]+)
    web_url: https://github.com/lucaslorentz/caddy-docker-proxy/releases
    icon: https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/svg/caddy.svg
    gotify:
      GOTIFY_NOTIFICATION: {}
    deployed_version:
      url: http://osu.logs:8069/caddy2/current_version.txt
      regex: caddy-docker-proxy/plugin/v2\s?(v[0-9.]+)
JosephKav commented 2 years ago

Screenshot_20220519-022241_Gotify ^ Ignore the fact that the version is wrong. This was run from the latest release and I made it regex_submatch but with an index of 0 (ignores the match brackets)

Copying your config gave me

ERROR: Unmarshal of "test.yml" failed
 yaml: line 16: block sequence entries are not allowed in this context

Line 16 being message: {{ service_id }} - {{ version }} released.. You just need to put this in quotes, e.g.

message: "{{ service_id }} - {{ version }} released."

samcro1967 commented 2 years ago

Looks like I copied the config before I saw that error and updated the config. I put single quotes around it to match the client_notificaton style. Just changed it to double quotes, but still not getting anything. Hmmm...

JosephKav commented 2 years ago

Could you send the logs please? Sounds like an issue with your Gotify server. Are you using the token of an application you created on it?

samcro1967 commented 2 years ago

I noticed that when I restart argus (after deleting the status section for caddy-docker-proxy from config.xml) and it updates the status for caddy-docker-proxy, it replaces the double quotes with single quotes. I am running an image a few commits ahead of 0.4.1.

I feel pretty good that Gotify is fine. I have about 20 channels setup and all of the others are working.

Logs

INFO: Found 27 services to monitor:
  - Argus
  - ...
  - CaddyDockerProxy
ERROR: Argus, Get "http://localhost:8111/api/v1/version": dial tcp 127.0.0.1:8111: connect: connection refused
INFO: Listening on 0.0.0.0:8111/argus
INFO: CaddyDockerProxy, Updated to "v2.0.0"
INFO: CaddyDockerProxy, Latest Release - "v2.6.0"
INFO: Saved service updates to /etc/argus/config.yml
samcro1967 commented 2 years ago

I enabled debug logging and I am not seeing any errors around anything related to Gotify in the logs. It is to large to put on pastebin or post here.

JosephKav commented 2 years ago

The single/double quotes thing shouldn't matter for this message text. If you're deleting the whole status then a message won't be sent when you next start as I didnt want to spam messages the first time you use a service. Also, if only current/latest_vsrsion is defined then I set it to default the other to the one that is defined. I'd say to test this alerting, change the latest_version (I don't think you need to do current for the notification, but maybe try that too if it doesn't alert),

samcro1967 commented 2 years ago

Still not having any luck.

I changed the update interval to 2 mins and pointed the latest version for caddy at a local file for testing. I set the version for both current and latest to 2.5.1. I started the container and waited until I saw the first Saved service updates to /etc/argus/config.yml and then updated the version in latest to 2.5.2. After 2 mins the status changed on the dashboard, but Gotify did not receive a notification. I changed the Gotify server from a DNS name to localhost and IP address, but neither worked.

I used another app and sent a test notification to Gotify using the Argus token and Gotify received the notification so I know the channel is ok. I installed ping and curl into the Argus container. I am able to ping the Gotify server by DNS name and IP address. I am also able to curl the Argus channel in Gotify and see the test notification.

I installed httpie into the Argus container and am able to push a message to the Argus channel in Gotify with the following from the Argus container:

http -f POST "http://osu.gotify:8132/message?token=<redacted>" title="my title" message="my mess
age" priority="5"

Another thing I noticed while troubleshooting this, as an FYI, is that comments in config.yml are removed after Saved service updates to /etc/argus/config.yml. I am using a hash to make comments. Is there another method for comments in config.xml?

I will set it up in a local repo for versioning as the file is getting large and I will want to keep track of changes. I normally use comments when I make changes so I can roll them back quickly.

JosephKav commented 2 years ago

Another thing I noticed while troubleshooting this, as an FYI, is that comments in config.yml are removed after Saved service updates to /etc/argus/config.yml. I am using a hash to make comments. Is there another method for comments in config.xml?

I could work on adding support for comments at some point, it's just a bit difficult as far as I know as Go will always write the yaml in the same order (unless it's a map) and won't read in any comments (afaik). Currently trying to get sorting for the new Notify maps as maps in Go are completely unordered, so it could be written in a differant order every time it's saved. I'm trying to alphabetise it and maybe in the future I'll make it read the file and match the ordering

JosephKav commented 2 years ago

It works for me on master?

❯ ./argus - no status
INFO: Found 1 services to monitor:
  - CaddyDockerProxy
INFO: Listening on 0.0.0.0:8111/
INFO: CaddyDockerProxy, Latest Release - "v2.6.0"
INFO: Saved service updates to config.yml
^C
❯ nano config.yml - change latest_version to 2.5.0
❯ ./argus
INFO: Found 1 services to monitor:
  - CaddyDockerProxy
INFO: Listening on 0.0.0.0:8111/
INFO: CaddyDockerProxy, New Release - "v2.6.0"
INFO: GOTIFY_NOTIFICATION (CaddyDockerProxy), Gotify message sent

Surely you get some kind of log that it's sent/trying to send to Gotify?

samcro1967 commented 2 years ago

I am a few commits ahead of master with some of the fixes you implemented. My version says development. Probably best to wait until you make a new release and I will retest then. I never see Gotify message sent in the container log.

JosephKav commented 2 years ago

My latest testing was on master, meaning GitHub master, which is a few commits ahead of the latest release

samcro1967 commented 2 years ago

I believe we are running the same version. My image was created as follows:

git clone https://github.com/release-argus/Argus.git
docker build -t argus .
docker-compose pull argus
docker-compose rm -f argus
docker-compose up -d

The version in Argus shows up as this: image

JosephKav commented 2 years ago

Lets try one last thing before we're gonna have to close this as I can't reproduce the issue. I've tried a few times with your config but no luck, the messages send as expected

Could you try running it again with this as your config.yml please?

settings:
  web:
    listen_host: 0.0.0.0
    listen_port: "8111"
    route_prefix: /
defaults:
  service:
    access_token: <redacted>
    interval: 30m
    deployed_version: {}
gotify:
  GOTIFY_NOTIFICATION:
    url: https://gotify.example.io
    token: <TOKEN>
    title: Argus Notification
    message: '{{ service_id }} - {{ version }} released.'
    extras:
      client_display: text/plain
      client_notification: '{{ web_url }}'
    priority: 5
    delay: 0s
    max_tries: 3
service:
  CaddyDockerProxy:
    type: url
    url: https://github.com/lucaslorentz/caddy-docker-proxy/tags
    semantic_versioning: false
    url_commands:
      - type: regex
        regex: releases\/tag\/(v[0-9.]+)
    web_url: https://github.com/lucaslorentz/caddy-docker-proxy/releases
    icon: https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/svg/caddy.svg
    gotify:
      GOTIFY_NOTIFICATION: {}
    status:
      current_version: v2.6.0
      current_version_timestamp: "2022-05-19T12:33:22Z"
      latest_version: v2.5.0
      latest_version_timestamp: "2022-05-19T12:33:22Z"

Share the logs that you get (they should be very short if you only use this 1 service and info log level) It almost instantly sends the message for me.

❯ ./argus
INFO: Found 1 services to monitor:
  - CaddyDockerProxy
INFO: Listening on 0.0.0.0:8111/
INFO: CaddyDockerProxy, New Release - "v2.6.0"
INFO: GOTIFY_NOTIFICATION (CaddyDockerProxy), Gotify message sent
^C
❯ ./argus
INFO: Found 1 services to monitor:
  - CaddyDockerProxy
INFO: Listening on 0.0.0.0:8111/
INFO: CaddyDockerProxy, New Release - "v2.6.0"
INFO: GOTIFY_NOTIFICATION (CaddyDockerProxy), Gotify message sent
samcro1967 commented 2 years ago

So that worked. Latest version was updated to v2.6.0 in config.yml. Which version is referring to the deployed version, current or latest?

JosephKav commented 2 years ago

current_version is the version of the deployed service

samcro1967 commented 2 years ago

So the only difference I am seeing is removing the following from the config:

    deployed_version:
      url: http://osu.logs:8069/caddy2/current_version.txt
      regex: caddy-docker-proxy/plugin/v2\s?(v[0-9.]+)

Or is there something else I missed?

In this instance I would have already been running v2.6.0 and would have been notified that v.2.6.0 is available. I would think notifications would only occur when a new version is available and it is newer than the version I am running.

I would suggest renaming current_version to deployed_version for consistency.

JosephKav commented 2 years ago

Ah that explains it. It'll be picking up the current_version from your deployed caddy and as that's the same as latest_version, it won't send any alerts

Good point about the current_version renaming to deployed_version. I agree that it makes more sense and will make a ticket so I don't forget. It wouldn't be a breaking change. I'll just have it parse deployed_version as well as current_version from the config then rename and store it as deployed_version, (then I'll remove this conversion a few versions later)

JosephKav commented 2 years ago

Mind if I close this? I believe it wasn't sending messages as you had the latest_version deployed, so it queried that and then when it queried the latest_version, that was already deployed so there was nothing to alert on. You did test that it worked if you removed the deployed_version checker. I've merged the Shoutrrr integration and will just wait a bit before I do the release, or until a get a few success responses confirming that it didn't break anything (without having to change their config.yml)

samcro1967 commented 2 years ago

Agreed. I think this one is resolved.