Metadata API reference

Detailed documentation on the Metadata API

Dapr has a metadata API that returns information about the sidecar allowing runtime discoverability. The metadata endpoint returns a list of the components loaded, the activated actors (if present) and attributes with information attached.

Components

Each loaded component provides its name, type and version and also information about supported features in the form of component capabilities. These features are available for the state store and binding component types. The table below shows the component type and the list of capabilities for a given version. This list might grow in future and only represents the capabilities of the loaded components.

Component typeCapabilities
State StoreETAG, TRANSACTION, ACTOR, QUERY_API
BindingINPUT_BINDING, OUTPUT_BINDING

Attributes

The metadata API allows you to store additional attribute information in the format of key-value pairs. These are ephemeral in-memory and are not persisted if a sidecar is reloaded. This information should be added at the time of a sidecar creation, for example, after the application has started.

Get the Dapr sidecar information

Gets the Dapr sidecar information provided by the Metadata Endpoint.

Usecase:

The Get Metadata API can be used for discovering different capabilities supported by loaded components. It can help operators in determining which components to provision, for required capabilities.

HTTP Request

  1. GET http://localhost:<daprPort>/v1.0/metadata

URL Parameters

ParameterDescription
daprPortThe Dapr port.

HTTP Response Codes

CodeDescription
200Metadata information returned
500Dapr could not return the metadata information

HTTP Response Body

Metadata API Response Object

NameTypeDescription
idstringApplication ID
actorsMetadata API Response Registered Actor[]A json encoded array of registered actors metadata.
extended.attributeNamestringList of custom attributes as key-value pairs, where key is the attribute name.
componentsMetadata API Response Component[]A json encoded array of loaded components metadata.

Metadata API Response Registered Actor

NameTypeDescription
typestringThe registered actor type.
countintegerNumber of actors running.

Metadata API Response Component

NameTypeDescription
namestringName of the component.
typestringComponent type.
versionstringComponent version.
capabilitiesarraySupported capabilities for this component type and version.

Examples

Note: This example is based on the Actor sample provided in the Dapr SDK for Python.

  1. curl http://localhost:3500/v1.0/metadata
  1. {
  2. "id":"demo-actor",
  3. "actors":[
  4. {
  5. "type":"DemoActor",
  6. "count":1
  7. }
  8. ],
  9. "extended": {
  10. "cliPID":"1031040",
  11. "appCommand":"uvicorn --port 3000 demo_actor_service:app",
  12. "daprRuntimeVersion": "1.10.0"
  13. },
  14. "components":[
  15. {
  16. "name":"pubsub",
  17. "type":"pubsub.redis",
  18. "version":"v1",
  19. "capabilities": [""]
  20. },
  21. {
  22. "name":"statestore",
  23. "type":"state.redis",
  24. "version":"v1",
  25. "capabilities": ["ETAG", "TRANSACTION", "ACTOR", "QUERY_API"]
  26. }
  27. ]
  28. }

Add a custom label to the Dapr sidecar information

Adds a custom label to the Dapr sidecar information stored by the Metadata endpoint.

Usecase:

The metadata endpoint is, for example, used by the Dapr CLI when running dapr in self hosted mode to store the PID of the process hosting the sidecar and store the command used to run the application. Applications can also add attributes as keys after startup.

HTTP Request

  1. PUT http://localhost:<daprPort>/v1.0/metadata/attributeName

URL Parameters

ParameterDescription
daprPortThe Dapr port.
attributeNameCustom attribute name. This is they key name in the key-value pair.

HTTP Request Body

In the request you need to pass the custom attribute value as RAW data:

  1. {
  2. "Content-Type": "text/plain"
  3. }

Within the body of the request place the custom attribute value you want to store:

  1. attributeValue

HTTP Response Codes

CodeDescription
204Custom attribute added to the metadata information

Examples

Note: This example is based on the Actor sample provided in the Dapr SDK for Python.

Add a custom attribute to the metadata endpoint:

  1. curl -X PUT -H "Content-Type: text/plain" --data "myDemoAttributeValue" http://localhost:3500/v1.0/metadata/myDemoAttribute

Get the metadata information to confirm your custom attribute was added:

  1. {
  2. "id":"demo-actor",
  3. "actors":[
  4. {
  5. "type":"DemoActor",
  6. "count":1
  7. }
  8. ],
  9. "extended": {
  10. "myDemoAttribute": "myDemoAttributeValue",
  11. "cliPID":"1031040",
  12. "appCommand":"uvicorn --port 3000 demo_actor_service:app"
  13. },
  14. "components":[
  15. {
  16. "name":"pubsub",
  17. "type":"pubsub.redis",
  18. "version":"v1",
  19. "capabilities": [""]
  20. },
  21. {
  22. "name":"statestore",
  23. "type":"state.redis",
  24. "version":"v1",
  25. "capabilities": ["ETAG", "TRANSACTION", "ACTOR", "QUERY_API"]
  26. }
  27. ]
  28. }

Last modified February 24, 2023: add daprRuntimeVersion to code example (#3208) (74865bff)