<p>I am running a rest service based on Eclipse Microprofile. My service provides a health check. The result of such a health check (which is providing a lot of information) looks for example like this:</p>

<pre><code>http://localhost:9990/health
HTTP=OK

{
  "status":"UP",
  "checks":[
    {"name":"imixs-workflow",
     "status":"UP",
     "data":
     {
     "engine.version":"5.1.11-SNAPSHOT",
     "model.groups":30,
     "model.versions":20
     }
    }
  ]
}
</code></pre>

<p>The service is healthy if the check named 'imixs-workflow' shows the 'status' 'UP'.</p>

<p>I already tried to configure this with a livenessprobe like this:</p>

<pre><code>livenessProbe:
  exec:
    command: ["sh", "-c", "curl -s http://localhost:9990/health| grep -q imixs-workflow"]
  initialDelaySeconds: 60
</code></pre>

<p>But this did not work. </p>

<p>How should I configure such a livenessprobe getting the status of a specific json field in a http result?</p>

Ralph
<p>Your liveness probe command should return status different from 0 to indicate unhealthy container condition. Please see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Configure Liveness, Readiness and Startup Probes</a>.</p>

<p>If possible, I'd also recommend for better maintainability and readability to use the tool called <a href="https://stedolan.github.io/jq/" rel="nofollow noreferrer">jq</a> - command-line JSON processor.</p>

<p>With it your probe should look something like this:</p>

<pre><code>livenessProbe:
  exec:
    command: ["sh", "-c", "curl -s http://localhost:9990/health | jq -e '.checks[] | select(.name == "imixs-workflow") | .status == "UP"']
  initialDelaySeconds: 60
</code></pre>

<p>Here <code>-e</code> flag sets exit status to 1 if the last output value was false.</p>
