Fresh Produce: _instances.internal For Easy Instance Metadata Querying

Sometimes, you need to query some lower-level info about individual machines that an app is running. You can already do some pretty cool stuff, like querying our DNS server for what regions an app has instances running in:

$ dig TXT vms.real-app.internal +short
"15874f91a0e235 ord"

You can do even more interesting things like find the closest 3 instances of an app:

$ dig TXT top3.nearest.of.real-app.internal +short
"ip=fdaa:1:73b7:a3b:8d31:d856:be8e:4,region=ord,ping=21.123183000000002;..."

This is all very exciting stuff! But what if we wanted to go even lower level? Recently, I wanted to track how much data was being sent from my app to other apps within my network, by tracking the amount of data sent to each 6PN or flycast address. I needed information on all of the instances that are running in my organization, their addresses, and what region they’re running in. I looked into it for a long time, but at the time there was simply no way to view what address corresponded to what instance, or for that matter what app or region.

Now, though, it’s an easy task. if we run a DNS TXT query on _instances.internal, we get an easy list of all instances we can process:

$ dig TXT _instances.internal +short
"instance=12374791ade2f5,app=real-app-1,ip=fdaa:1:73b7:a7b:ac7:c42:6d64:4,region=iad;instance=3135929c29d938,app=real-app-2,ip=fdaa:1:73b7:a7b:8c=d31:c356:a18e:2,region=ord;instance=148d0100e35173,..."

With an easy to read Regex, we can extract out each instance’s information, and as an example, search for which instance is assigned to an IP:
instance=([a-f0-9]*),app=(.*),ip=fdaa:1:73b7:a7b:ac7:c42:6d64:4,region=([a-z]*);.
(You could probably write a good parser for this instead, but Regex solves all our problems.

We have even more .internal addresses for doing even more cool meta things, check them out!

5 Likes