{"action":"created","issue":{"url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/230","repository_url":"https://api.github.com/repos/zalando-zmon/zmon-controller","labels_url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/230/comments","events_url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/230/events","html_url":"https://github.com/zalando-zmon/zmon-controller/issues/230","id":165395081,"number":230,"title":"How does creating entities work?","user":{"login":"ePaul","id":645859,"avatar_url":"https://avatars.githubusercontent.com/u/645859?v=3","gravatar_id":"","url":"https://api.github.com/users/ePaul","html_url":"https://github.com/ePaul","followers_url":"https://api.github.com/users/ePaul/followers","following_url":"https://api.github.com/users/ePaul/following{/other_user}","gists_url":"https://api.github.com/users/ePaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ePaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ePaul/subscriptions","organizations_url":"https://api.github.com/users/ePaul/orgs","repos_url":"https://api.github.com/users/ePaul/repos","events_url":"https://api.github.com/users/ePaul/events{/privacy}","received_events_url":"https://api.github.com/users/ePaul/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-13T18:54:35Z","updated_at":"2016-09-02T17:25:19Z","closed_at":"2016-08-03T21:54:24Z","body":"http://zmon.readthedocs.io/en/latest/user/entities.html (or equally, https://docs.zmon.io/en/latest/user/entities.html) mention that there is a REST API for creating entities, but don't really go into detail.\r\n\r\nI wanted to monitor my Jenkins jobs (to see an alert when one of them is failing). So I thought I add two entities and upload them via CLI:\r\n\r\n```yaml\r\n- type: jenkins-job\r\n  id: lumberjack:purchasing-backend-build\r\n  team: lumberjack\r\n  url: https://lumberjack-jenkins.example.com/job/purchasing-backend-build/\r\n- type: jenkins-job\r\n  id: lumberjack:tarbela-build\r\n  team: lumberjack\r\n  url: https://lumberjack-jenkins.example.com/job/tarbela-build/\r\n```\r\n```\r\n$ zmon entities push entities.yaml \r\nCreating entity lumberjack:purchasing-backend-build..failed\r\nCreating entity lumberjack:tarbela-build..failed\r\n```\r\n(The commands exits with code 0, which normally indicates success.)\r\n\r\nI have no idea what failed here. I can guess that it didn't like the entity type (can I create an entity type by creating an entity, or can I just use existing ones? Or do I have to create the type first? Which types are there, actually?), do those IDs already exist, or I'm not authorized to create entities (which might relate to #223), or any other reason?\r\n\r\n\r\n(I planned to have a check command which filters for this type (and possible the alert filters for the team), then uses  `http(entity['url'] + '/api/json?tree=color').json()['color']` as the check command, which then an alert can use for condition `value != \"blue\"`. It already works in trial run for GLOBAL with a hardcoded URL.)\r\n\r\nIs what I want to do actually doable, or do I need a separate check for each job?\r\n\r\nPS: I didn't find any documentation about the REST API either, other than [See CLI entities](https://docs.zmon.io/en/latest/developer/rest-api.html#entities). Shouldn't there be a Swagger/OpenAPI definition somewhere?"},"comment":{"url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/comments/244437184","html_url":"https://github.com/zalando-zmon/zmon-controller/issues/230#issuecomment-244437184","issue_url":"https://api.github.com/repos/zalando-zmon/zmon-controller/issues/230","id":244437184,"user":{"login":"ePaul","id":645859,"avatar_url":"https://avatars.githubusercontent.com/u/645859?v=3","gravatar_id":"","url":"https://api.github.com/users/ePaul","html_url":"https://github.com/ePaul","followers_url":"https://api.github.com/users/ePaul/followers","following_url":"https://api.github.com/users/ePaul/following{/other_user}","gists_url":"https://api.github.com/users/ePaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ePaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ePaul/subscriptions","organizations_url":"https://api.github.com/users/ePaul/orgs","repos_url":"https://api.github.com/users/ePaul/repos","events_url":"https://api.github.com/users/ePaul/events{/privacy}","received_events_url":"https://api.github.com/users/ePaul/received_events","type":"User","site_admin":false},"created_at":"2016-09-02T17:25:19Z","updated_at":"2016-09-02T17:25:19Z","body":"Okay, problem solved.\r\n\r\nFor the record (some of this might be specific for the setup in Zalando):\r\n\r\nEntities whose checks need to run in specific AWS accounts (i.e. in the ZMON-scheduler+worker in the appliance deployed there) need to have the `infrastructure_account` field and/or a `[aws:<account>:<region>]` part in the ID (I hope the details will be documented soon).\r\n\r\nAll entities without a `infrastructure_account` field will be handled by the zmon-scheduler in one of the datacenters for checks. Unfortunately the latter doesn't work for Trial run, so you actually need something like `\"infrastructure_account\":\"dc:gth\"` (or a different one) in the entity for Trial run to pick them up.\r\n\r\n-------\r\n\r\nSo this is how my entities look like:\r\n\r\n```yaml\r\n- type: jenkins_job\r\n  id: lumberjack:purchasing-backend-build\r\n  team: Lumberjack\r\n  url: https://lumberjack-jenkins.example.com/job/purchasing-backend-build/\r\n  infrastructure_account: dc:gth\r\n- type: jenkins_job\r\n  id: lumberjack:tarbela-build\r\n  team: Lumberjack\r\n  url: https://lumberjack-jenkins.example.com/job/tarbela-build/\r\n  infrastructure_account: dc:gth\r\n```\r\n\r\nHere is my check-definition:\r\n\r\n```yaml\r\nname: Check the status of a Jenkins Job\r\nowning_team: Lumberjack\r\ndescription: |-\r\n  This check retrieves the \"color\" (i.e. status) of a Jenkins Job.\r\n  I think \"blue\" means okay, other statuses might mean failures of different kinds.\r\ncommand: |-\r\n  http('api/json?tree=color', timeout=30).json()['color']\r\ninterval: 200\r\nentities:\r\n- type: jenkins_job\r\nstatus: ACTIVE\r\n```\r\n\r\nAnd here the corresponding alert definition for our team:\r\n```yaml\r\ncheck_definition_id: (the ID of the check above)\r\nname: Failing Jenkins Build for {entities}\r\nteam: Lumberjack\r\nresponsible_team: Lumberjack\r\ndescription: |-\r\n  This alert pops up when a Jenkins build is failing.\r\ncondition: |-\r\n  value != \"blue\"\r\nentities:\r\n- team: Lumberjack\r\nentities_exclude: []\r\nstatus: ACTIVE\r\nnotifications: []\r\nperiod: ''\r\npriority: 2\r\ntags:\r\n- jenkins\r\ntemplate: false\r\n```\r\n\r\n@Jan-M Feel free to use whatever you want from this for the documentation update as examples."}}
{"actor":{"display_login":"ePaul"}}