getting started tutorial<\/a> to learn more.<\/p>\n\n\n\nListing all metadata<\/h2>\n\n\n\n
Metadata is available to be queried through all networks: public, utility and SDN private networks.<\/p>\n\n\n\n
The metadata is available as a cloud-init compatible JSON and via a filesystem-like traversable API. Both can be queried on any of your cloud servers using any HTTP client such as curl<\/tt> or wget<\/tt>.<\/p>\n\n\n\n
For example, you can use the following request to view all of the metadata available on your cloud server.<\/p>\n\n\n\n
curl http:\/\/169.254.169.254\/metadata\/v1.json<\/pre>\n\n\n\n{\n \"cloud_name\": \"upcloud\",\n \"instance_id\": \"00bf9504-a4cb-4839-88ff-124a2c95e169\",\n \"hostname\": \"metadata.example.com\",\n \"platform\": \"servers\",\n \"subplatform\": \"metadata (http:\/\/169.254.169.254)\",\n \"public_keys\": [\n \"ssh-rsa AAAAB[...]ud1Cw== max@upcloud.com\"\n ],\n \"region\": \"de-fra1\",\n \"network\": {\n \"interfaces\": [\n {\n \"index\": 1,\n \"ip_addresses\": [\n {\n \"address\": \"94.237.90.209\",\n \"dhcp\": true,\n \"dns\": [\n \"94.237.127.9\",\n \"94.237.40.9\"\n ],\n \"family\": \"IPv4\",\n \"floating\": false,\n \"gateway\": \"94.237.90.1\",\n \"network\": \"94.237.90.0\/24\"\n }\n ],\n \"mac\": \"de:ad:be:ef:3f:c5\",\n \"network_id\": \"03030473-8e9d-4f4f-bcfe-b2c300391a07\",\n \"type\": \"public\"\n },\n {\n \"index\": 2,\n \"ip_addresses\": [\n {\n \"address\": \"10.199.12.11\",\n \"dhcp\": true,\n \"dns\": null,\n \"family\": \"IPv4\",\n \"floating\": false,\n \"gateway\": \"10.199.12.1\",\n \"network\": \"10.199.12.0\/24\"\n }\n ],\n \"mac\": \"de:ad:be:ef:9f:ff\",\n \"network_id\": \"03318153-4e70-4ba5-8e74-69538582188d\",\n \"type\": \"utility\"\n },\n {\n \"index\": 3,\n \"ip_addresses\": [\n {\n \"address\": \"2a04:3540:1000:811:9809:21ff:fe8b:5962\",\n \"dhcp\": true,\n \"dns\": [\n \"2a04:3540:53::1\",\n \"2a04:3544:53::1\"\n ],\n \"family\": \"IPv6\",\n \"floating\": false,\n \"gateway\": \"2a04:3540:1000:811::1\",\n \"network\": \"2a04:3540:1000:811::\/64\"\n }\n ],\n \"mac\": \"9a:09:21:8b:59:62\",\n \"network_id\": \"03000000-0000-4000-8002-000000000000\",\n \"type\": \"public\"\n }\n ],\n \"dns\": [\n \"94.237.127.9\",\n \"94.237.40.9\"\n ]\n },\n \"storage\": {\n \"disks\": [\n {\n \"id\": \"0187b8c5-7220-4c90-9026-047dff8be0b3\",\n \"serial\": \"0187b8c572204c909026\",\n \"size\": 25,\n \"type\": \"disk\",\n \"tier\": \"maxiops\"\n }\n ]\n },\n \"tags\": [\n \"dev\",\n \"metadata\"\n ],\n \"user_data\": \"apt-get update && apt-get -y upgrade\",\n \"vendor_data\": \"\"\n}<\/pre>\n\n\n\nGetting specific metadata<\/h2>\n\n\n\n
UpCloud metadata service can also be accessed via a filesystem-like traversable API. This allows you to find specific data about resources that can include multiples of the same type, for example, storage and networks.<\/p>\n\n\n\n
List all available fields with the following request.<\/p>\n\n\n\n
curl http:\/\/169.254.169.254\/metadata\/v1\/<\/pre>\n\n\n\ncloud_name\ninstance_id\nhostname\nplatform\nsubplatform\npublic_keys\nregion\nnetwork\/\nstorage\/\ntags\nuser_data\nvendor_data<\/pre>\n\n\n\nSpecific information can be retrieved using the full path of the field, for example, with the request below to get the cloud server region.<\/p>\n\n\n\n
curl http:\/\/169.254.169.254\/metadata\/v1\/region<\/pre>\n\n\n\nfi-hel1<\/pre>\n\n\n\nData fields with the \/ icon at the end indicate nested fields that work like directories. You can traverse these directories to view their content. For example, you can list the network interfaces using the request below.<\/p>\n\n\n\n
curl http:\/\/169.254.169.254\/metadata\/v1\/network\/interfaces\/<\/pre>\n\n\n\n1\/\n2\/\n3\/<\/pre>\n\n\n\nYou can get detailed information about any of the network interfaces by going further into the data structure. For example, find the IP address on the first interface which usually holds the public IP.<\/p>\n\n\n\n
curl http:\/\/169.254.169.254\/metadata\/v1\/network\/interfaces\/1\/ip_addresses\/0\/address<\/pre>\n\n\n\n94.237.90.209<\/pre>\n\n\n\nThe metadata can then be used to configure applications and services which require server-specific information that is not known before deployment.<\/p>\n","protected":false},"featured_media":13989,"comment_status":"open","ping_status":"closed","template":"","community-category":[109,117,122],"class_list":["post-24879","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry","community-category-upcloud-services","community-category-automation","community-category-api"],"acf":[],"_links":{"self":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial\/24879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/types\/tutorial"}],"replies":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/comments?post=24879"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media\/13989"}],"wp:attachment":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media?parent=24879"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/community-category?post=24879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}