Detecting sensor failiure in ekf

As far as i have understood, in px4 ekf automatically switches between instances if some failure happens. I need to know that a particular sensor has failed and hence the switching is happening. Is there a way to know that?

You can check the EKF document in docs. The keyword you should focus on “innovation” values. You can dedect which sensor has failed by using these values.

You see the ID of the selected (actively fused) accel/gyro in sensor_status_imu.accel_device_id_primary or in estimator_status.accel_device_id