# ask-ai


02/20/2024, 7:18 AM
how do i access a job metadata in a sensor?


02/20/2024, 7:18 AM
To access job metadata within a sensor, you would typically use the context object provided to the sensor function to query the Dagster instance for the relevant metadata. However, the documentation does not explicitly provide an example or a method for accessing job metadata directly within a sensor. If you need to access metadata related to a specific asset materialization within a sensor, the documentation provides an example of how to do this using the context object to query the event log for the latest materialization event of an asset. Here is an example from the documentation for accessing metadata from a historical materialization of one asset from inside another asset:
Copy code
python @asset def asset1():     return Output(value=..., metadata={"num_rows": 5})  @asset  # or op def asset_1_num_rows(context):     instance = context.instance     materialization = instance.get_latest_materialization_event(AssetKey(["asset1"])).asset_materialization     return materialization.metadata["num_rows"]
In the case of job metadata, if the metadata you are interested in is attached to the job as tags or custom metadata, and you want to access it within a sensor, you might need to query the Dagster instance for the specific job and then extract the metadata from the job definition. However, this approach is not detailed in the documentation, and it may not be directly supported. If the documentation does not cover your specific use case, and you are unable to find a method to access job metadata within a sensor, you might consider reaching out to the Dagster community or checking the GitHub issues and discussions for any related topics or feature requests that might provide further guidance.