{"action":"created","issue":{"url":"https://api.github.com/repos/coredns/coredns/issues/1492","repository_url":"https://api.github.com/repos/coredns/coredns","labels_url":"https://api.github.com/repos/coredns/coredns/issues/1492/labels{/name}","comments_url":"https://api.github.com/repos/coredns/coredns/issues/1492/comments","events_url":"https://api.github.com/repos/coredns/coredns/issues/1492/events","html_url":"https://github.com/coredns/coredns/issues/1492","id":294868102,"number":1492,"title":"plugin/metrics: only metrics from a single zone block are reported [BUG]","user":{"login":"achille-roussel","id":865510,"avatar_url":"https://avatars3.githubusercontent.com/u/865510?v=4","gravatar_id":"","url":"https://api.github.com/users/achille-roussel","html_url":"https://github.com/achille-roussel","followers_url":"https://api.github.com/users/achille-roussel/followers","following_url":"https://api.github.com/users/achille-roussel/following{/other_user}","gists_url":"https://api.github.com/users/achille-roussel/gists{/gist_id}","starred_url":"https://api.github.com/users/achille-roussel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achille-roussel/subscriptions","organizations_url":"https://api.github.com/users/achille-roussel/orgs","repos_url":"https://api.github.com/users/achille-roussel/repos","events_url":"https://api.github.com/users/achille-roussel/events{/privacy}","received_events_url":"https://api.github.com/users/achille-roussel/received_events","type":"User","site_admin":false},"labels":[{"id":343986366,"url":"https://api.github.com/repos/coredns/coredns/labels/bug","name":"bug","color":"fc2929","default":true},{"id":776346072,"url":"https://api.github.com/repos/coredns/coredns/labels/plugin/metrics","name":"plugin/metrics","color":"70e0b1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/coredns/coredns/milestones/12","html_url":"https://github.com/coredns/coredns/milestone/12","labels_url":"https://api.github.com/repos/coredns/coredns/milestones/12/labels","id":2693785,"number":12,"title":"1.1.0","description":"","creator":{"login":"miekg","id":353371,"avatar_url":"https://avatars1.githubusercontent.com/u/353371?v=4","gravatar_id":"","url":"https://api.github.com/users/miekg","html_url":"https://github.com/miekg","followers_url":"https://api.github.com/users/miekg/followers","following_url":"https://api.github.com/users/miekg/following{/other_user}","gists_url":"https://api.github.com/users/miekg/gists{/gist_id}","starred_url":"https://api.github.com/users/miekg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miekg/subscriptions","organizations_url":"https://api.github.com/users/miekg/orgs","repos_url":"https://api.github.com/users/miekg/repos","events_url":"https://api.github.com/users/miekg/events{/privacy}","received_events_url":"https://api.github.com/users/miekg/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":4,"state":"open","created_at":"2017-08-10T08:18:04Z","updated_at":"2018-03-01T01:19:29Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2018-02-06T18:37:35Z","updated_at":"2018-03-01T22:32:53Z","closed_at":null,"author_association":"NONE","body":"I'm observing what I believe is not the expected behavior with the metrics plugin (or at least not the documented behavior). \r\n\r\nConsidering a configuration like this:\r\n```\r\n.com {\r\n  proxy . 127.0.0.1:53\r\n  autopath /zones.conf\r\n  prometheus :9053\r\n}\r\n\r\n. {\r\n  proxy . 127.0.0.1:53\r\n  prometheus :9053\r\n}\r\n```\r\nThe `coredns_dns_` metrics which are generated by each metrics plugin are properly reported for both zones, however the metrics of the proxy and autopath plugins are not. Either metrics of the `.com` and `.` zones are reported. I haven't been able to determine which block takes priority, it seems kind of random.\r\n\r\nThe issue I believe comes from the fact that plugins in each zone will be attached to the `*metrics.Metrics` instance of their block (see this example https://github.com/coredns/coredns/blob/master/plugin/cache/setup.go#L33-L48), but only one `*metrics.Metrics` instance is configured to listen on a pair of IP and port (see https://github.com/coredns/coredns/blob/master/plugin/metrics/setup.go#L32-L39 and https://github.com/coredns/coredns/blob/master/plugin/metrics/metrics.go#L87-L104).\r\nThis results in having some plugins _wired_ to a metrics instance that is not serving requests.\r\n\r\nA possible solution would be to share the `*prometheus.Registry` between `*metrics.Metrics` instances that are configured to be served on the same port. It means the `(*metrics.Metrics).MustRegister` method must be revisited to not panic when a metric is registered multiple times by multiple instantiations of a plugin.\r\n\r\nI'm available to send a fix, but I wanted to get another pair of eyes on it in case I missed something."},"comment":{"url":"https://api.github.com/repos/coredns/coredns/issues/comments/369754470","html_url":"https://github.com/coredns/coredns/issues/1492#issuecomment-369754470","issue_url":"https://api.github.com/repos/coredns/coredns/issues/1492","id":369754470,"user":{"login":"miekg","id":353371,"avatar_url":"https://avatars1.githubusercontent.com/u/353371?v=4","gravatar_id":"","url":"https://api.github.com/users/miekg","html_url":"https://github.com/miekg","followers_url":"https://api.github.com/users/miekg/followers","following_url":"https://api.github.com/users/miekg/following{/other_user}","gists_url":"https://api.github.com/users/miekg/gists{/gist_id}","starred_url":"https://api.github.com/users/miekg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miekg/subscriptions","organizations_url":"https://api.github.com/users/miekg/orgs","repos_url":"https://api.github.com/users/miekg/repos","events_url":"https://api.github.com/users/miekg/events{/privacy}","received_events_url":"https://api.github.com/users/miekg/received_events","type":"User","site_admin":false},"created_at":"2018-03-01T22:32:53Z","updated_at":"2018-03-01T22:32:53Z","author_association":"OWNER","body":"`Server.Addr` has this i.e. `dns://:1053` which we can just use in an `addr` label - this should guarantee enough uniqueness."}}
{"actor":{"display_login":"miekg"}}