tumblr / collins

groovy kind of love
tumblr.github.com/collins
Apache License 2.0
571 stars 99 forks source link

Monitoring tab missing #475

Closed discordianfish closed 7 years ago

discordianfish commented 7 years ago

Hi,

I have this monitoring section in my production.conf, yet the monitoring "tab" doesn't show up:

monitoring {
  enabled = true
  GenericFrame {
    urlTemplate = "https://prometheus/consoles/node-overview.html?instance=%s"
  }
}
william-richard commented 7 years ago

Sorry, it looks like this was changed and not documented. Can you try this?

views {
  enabled = true
  frames = {
    monitoring {
      enabled = true
      urlScript = """ function(asset) { return "https://prometheus/consoles/node-overview.html?instance=" + obj.ATTRIBS[0]["HOSTNAME"];}"""
    }
  }
}

I'll make a note to myself to document this.

william-richard commented 7 years ago

Or if the person who wrote it cough @maddalab cough could submit docs, that would be awesome too 😝

discordianfish commented 7 years ago

@Primer42 This isn't working, it causes collins to fail with that misleading [error] application - Failed to create assetlog error (see #398). So something is wrong with that config snippet..

william-richard commented 7 years ago

Maybe try script instead of urlScript like it has in this example? https://github.com/tumblr/collins/blob/master/conf/reference/views_reference.conf It's very possible that urlScript doesn't actually work - I made my code snippet before based on the FrameConfig class in the code so I'm probably wrong about that config.

yl3w commented 7 years ago

example here https://github.com/tumblr/collins/blob/master/conf/dev_base.conf#L25

yl3w commented 7 years ago

In retrospect the change to arbitrary frames made is more flexible / script-able, do what you want - we used it at Tumblr, but made the common case more involved.

https://github.com/tumblr/collins/commit/7109b1e087a8f22e35c9b39548a2bfc75ff8de14

The difference was, you could now use this for any asset type.

The change implements the use of javascript call back to determine availability of the frame and supports arbitrary frame, which can be used for any asset type.

yl3w commented 7 years ago

The commit message includes this, which should get you there.

Implementing the monitoring frame

views {
  enabled = true
  frames = {
    monitoring {
      enabled = true
      title = "Monitoring"
      style = "width: 100%;height: 1200px;"
      script = """
        function isEnabled(inp) {
          var obj = JSON.parse(inp);
          return ((obj.ASSET.TYPE === "SERVER_NODE") && ("HOSTNAME" in obj.ATTRIBS[0]));
        }
        function getUrl(inp) {
          var obj = JSON.parse(inp);
          return "https://icinga2.ewr01.tumblr.net/thruk/cgi-bin/status.cgi?host=" + obj.ATTRIBS[0]["HOSTNAME"];
        }
      """
    }
  }
}```
discordianfish commented 7 years ago

Thanks! That worked. Would be great to see it in the docs :)

byxorna commented 7 years ago

@maddalab @Primer42 @discordianfish FWIW we use the flexible frames as well, and it works fantastically. We should add it into docs (and possibly update the demo configs) as well.

byxorna commented 7 years ago

https://tumblr.github.io/collins/configuration.html#views :)