# Fleet UI - Runtime Field

**URL:** <https://discuss.elastic.co/t/fleet-ui-runtime-field/370701>\
**Category:** Elastic Agent\
**Created:** [November 18, 2024, 3:03pm UTC](https://discuss.elastic.co/t/fleet-ui-runtime-field/370701 "2024-11-18T15:03:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikg](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@erikg](https://discuss.elastic.co/u/erikg)\
**Post date:** [November 18, 2024, 3:03pm UTC](https://discuss.elastic.co/t/fleet-ui-runtime-field/370701/1 "2024-11-18T15:03:46Z")

</div>

Hello,  
I am working on my own fleet custom dashboard and noticed that the Status field like "Unhealthy" , "Healthy", "Offline", etc are not added to the .fleet-agents-\* index.  
Is there any logic or perhaps a runtime field I can add to include the status?

---

<div class="post-metadata">

**Author:** ![erikg](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@erikg](https://discuss.elastic.co/u/erikg)\
**Post date:** [November 19, 2024, 5:42pm UTC](https://discuss.elastic.co/t/fleet-ui-runtime-field/370701/2 "2024-11-19T17:42:35Z")

</div>

Hello,

I have created a runtime field to display a fleet.status field  
long currentTimeMillis = System.currentTimeMillis();

```
      if (doc['unenrolled_at'].size() > 0) {
        emit('Unenrolled');
        return;
      }
      
      if (doc['last_checkin'].size() > 0) {
        long lastCheckinMillis = doc['last_checkin'].value.toInstant().toEpochMilli();
        // Consider an agent offline if it hasn't checked in for more than 5 minutes
        if (lastCheckinMillis < currentTimeMillis - 300000) {
          emit('Offline');
          return;
        }
      }
      
      if (doc['last_checkin_status'].size() > 0) {
        String status = doc['last_checkin_status'].value;
        if (status == 'online') {
          emit('Healthy');
        } else if (status == 'error') {
          emit('Unhealthy');
        } else if (status == 'updating') {
          emit('Updating');
        } else if (status == 'DEGRADED') {
          emit('Unhealthy');
        } else if (status == 'starting') {
          emit('Updating');
        } else {
          emit('Unknown');
        }
      } else {
        emit('Unknown');
      }

```

I was then able to create a custom dashboard using that same index:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/2/124e02b00434f9e43a68ba34b2c35ba9947bd6fe.png)

---

<div class="post-metadata">

**Author:** ![strawgate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/strawgate/32/131008_2.png) [@strawgate](https://discuss.elastic.co/u/strawgate)\
**Post date:** [November 19, 2024, 6:11pm UTC](https://discuss.elastic.co/t/fleet-ui-runtime-field/370701/3 "2024-11-19T18:11:09Z")

</div>

Glad you were able to come up with something you're happy with.

You can view the logic Fleet uses to populate the status field here [kibana/x-pack/plugins/fleet/common/services/agent\_status.ts at main · elastic/kibana · GitHub](https://github.com/elastic/kibana/blob/main/x-pack/plugins/fleet/common/services/agent_status.ts)

For example, the "Updating" status in the Fleet UI is any of `'(status:updating or status:unenrolling or status:enrolling)'`
