COREDNS-METADATA(7)

πŸ“¦
version 1.15.0 Β· 2 versions
, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… COREDNS-METADATA(7) β€” the metadata plugin, explained bestie-to-bestie

okay so this is page 7 of the CoreDNS plugins manual, and it's about the metadata plugin. it's short, it's sweet, and honestly it's kind of important β€” let's get into it πŸŽ€


✨ NAME ✨

metadata β€” it enables a metadata collector. that's it. that's the whole name section. iconic brevity πŸ’…


🌸 DESCRIPTION 🌸

okay so here's the vibe. by enabling metadata, any plugin that implements the metadata.Provider interface gets called for every single DNS query β€” at the very beginning of the process for that query β€” so it can add its own little metadata to the context. like everyone getting a lil name tag at the door 🫢

the metadata.Provider interface lives right here, and yes you should look at it:

https://godoc.org/github.com/coredns/coredns/plugin/metadata#Provider

the metadata that gets collected is then available to all plugins, through the Context parameter that's provided in the ServeDNS function. the package (code) documentation has examples on how to inspect and retrieve metadata that a plugin might be interested in β€” so if you're wondering "how do i actually read this stuff", that's where you go πŸ”₯

how does the metadata actually get added? by setting a label with a value in the context. these labels should be named plugin/NAME, where NAME is something descriptive. and the only hard requirement the metadata plugin actually enforces? the labels have to contain a slash. that's the whole rule. see the documentation for metadata.SetValueFunc for the details ✨

the value that gets stored is a string. and an empty string is the signal for "no metadata". see the documentation for metadata.ValueFunc on how to retrieve this πŸ’–


πŸ¦‹ SYNTAX πŸ¦‹

metadata [ZONES... ]
  • ZONES... β€” the zones that metadata should be invoked for πŸŽ€

πŸ‘‘ PLUGINS πŸ‘‘

so the metadata.Provider interface needs to be implemented by each plugin that's willing to provide metadata information for other plugins. it gets called by metadata and gathers the information from all the plugins in context. teamwork, makes the dream work, fr fr πŸ’œ

note: this method should work quickly, because it is called for every request. like, every. single. one. so please don't do anything heavy in there bestie 😭

🌈 EXAMPLES 🌈

the rewrite plugin uses meta data to rewrite requests. slay πŸ¦‹


⭐ SEE ALSO ⭐


and that's the page!! πŸ’– this was CoreDNS, from March 2026, and you just read COREDNS-METADATA(7) β€” go forth and collect that metadata, you absolute main character πŸ‘‘βœ¨

πŸ“¦ where this page comes from