tlkamp / litter-exporter

A Prometheus exporter for the Litter Robot 3 Connect
MIT License
7 stars 0 forks source link

Exporter never runs getStates function in litter-api lib #21

Closed Starttoaster closed 2 years ago

Starttoaster commented 2 years ago

I figured at this point it would be more appropriate for me to create a separate Issue, and I appreciate all your help so far. But I'm hitting a problem that might require a stronger understanding of the litter robot API and library that I don't have yet. I suspect one possibility that this is an issue of me having the newer Litter Robot 4. Perhaps something in the API changed for the newer model?

I set my log level to debug to get to the bottom of it and ended up somewhere closer to an answer :smile:

robot_1  | time="2022-07-21T02:26:49Z" level=debug msg="Trying to login to the Litter Robot API"
robot_1  | time="2022-07-21T02:26:50Z" level=debug msg="Login to the Litter Robot API succeeded"
robot_1  | time="2022-07-21T02:26:50Z" level=info msg="Starting exporter on 0.0.0.0:9080"

From here I waited 10 minutes for more logs to pop up, but they never did. Eventually I will get a token was refreshed successfully message if I leave it going long enough, but nothing else. I would have expected to eventually see the log line from https://github.com/tlkamp/litter-api/blob/0a677fdfeea1272a442b7752fde4a29a600ccc1e/client.go#L175

Here's my docker-compose.yml file:

version: '3'
services:
  robot:
    image: tlkamp/litter-exporter:latest
    command:
      - -email
      - redacted@gmail.com
      - -password
      - redacted
      - -api-key
      - p7ndMoj61npRZP5CVz9v4Uj0bG769xy6758QRBPb
      - -client-id
      - "IYXzWN908psOm7sNpe4G.ios.whisker.robots"
      - -client-secret
      - "C63CLXOmwNaqLTB2xXo6QIWGwwBamcPuaul"
      - -log-level
      - "debug"
    ports:
      - 9080:9080

Looking in my browser, I don't see any of the litter robot related metrics 🤔

When I get some time I'll have to run this through a debugger, I just haven't had the time yet. Maybe this weekend.

Starttoaster commented 2 years ago

Nevermind, 😮‍💨 , this is not the issue and I'm still not onto anything. I made this Issue thinking the expected behavior was for it to collect in the background but it's running that function when I refresh the exporter in my browser window.

robot_1  | time="2022-07-21T03:33:12Z" level=debug msg="Trying to fetch data from the Litter Robot API"
robot_1  | time="2022-07-21T03:33:12Z" level=debug msg="Fetching data from the Litter Robot API succeeded"

It's saying it's successfully collected that data from the LR API. At this point I'll probably fork the litter-api repo and start playing around. Perhaps there's still something here that's different from the Litter Robot 3 output that is making it not publish LR metrics on my exporter. I'm going to close this for now as I'm not entirely sure what the issue is yet.

tlkamp commented 2 years ago

Sorry it's taken me a while to get back to this one.

I don't have a litter robot 4 to test with and I'm not really in need of an upgrade, so I can't help troubleshoot directly but I don't expect the APIs to be that different if the features are largely the same.

In the litter-api project there is a unit test that requires a few environment variables be set - if you supply it your login information and robot name, it should give you a pass/fail status. From there, you can use the test to output things from the API and see where things are hanging up.

Let me know what you find!