Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(add): Readarr Support #97

Merged
merged 1 commit into from
Mar 4, 2023
Merged

feat(add): Readarr Support #97

merged 1 commit into from
Mar 4, 2023

Conversation

rtrox
Copy link
Collaborator

@rtrox rtrox commented Mar 3, 2023

Description of the change

This PR adds preliminary Readarr support to Exportarr. As Readarr is pre-beta, this support should be thought of as "experimental" (and is labeled as such in the README change). Example Metric Output (note all shared collectors are supported, but my test instance does not return any issues or queued items).

Example Metrics:

# HELP readarr_author_downloaded_total Total number of downloaded authors
# TYPE readarr_author_downloaded_total gauge
readarr_author_downloaded_total{url="https://readarr.redacted.tld"} 8
# HELP readarr_author_filesize_bytes Total filesize of all authors in bytes
# TYPE readarr_author_filesize_bytes gauge
readarr_author_filesize_bytes{url="https://readarr.redacted.tld"} 9.46947068e+08
# HELP readarr_author_monitored_total Total number of monitored authors
# TYPE readarr_author_monitored_total gauge
readarr_author_monitored_total{url="https://readarr.redacted.tld"} 22
# HELP readarr_author_total Total number of authors
# TYPE readarr_author_total gauge
readarr_author_total{url="https://readarr.redacted.tld"} 24
# HELP readarr_author_unmonitored_total Total number of unmonitored authors
# TYPE readarr_author_unmonitored_total gauge
readarr_author_unmonitored_total{url="https://readarr.redacted.tld"} 2
# HELP readarr_book_downloaded_total Total number of downloaded books
# TYPE readarr_book_downloaded_total gauge
readarr_book_downloaded_total{url="https://readarr.redacted.tld"} 246
# HELP readarr_book_grabbed_total Total number of grabbed books
# TYPE readarr_book_grabbed_total gauge
readarr_book_grabbed_total{url="https://readarr.redacted.tld"} 0
# HELP readarr_book_missing_total Total number of missing books
# TYPE readarr_book_missing_total gauge
readarr_book_missing_total{url="https://readarr.redacted.tld"} 119
# HELP readarr_book_monitored_total Total number of monitored books
# TYPE readarr_book_monitored_total gauge
readarr_book_monitored_total{url="https://readarr.redacted.tld"} 298
# HELP readarr_book_total Total number of books
# TYPE readarr_book_total gauge
readarr_book_total{url="https://readarr.redacted.tld"} 341
# HELP readarr_book_unmonitored_total Total number of unmonitored books
# TYPE readarr_book_unmonitored_total gauge
readarr_book_unmonitored_total{url="https://readarr.redacted.tld"} 828
# HELP readarr_history_total Total number of item in the history
# TYPE readarr_history_total gauge
readarr_history_total{url="https://readarr.redacted.tld"} 1335
# HELP readarr_queue_total Total number of items in the queue by status, download_status, and download_state
# TYPE readarr_queue_total gauge
readarr_queue_total{download_state="importFailed",download_status="warning",status="completed",url="https://readarr.redacted.tld"} 4
# HELP readarr_rootfolder_freespace_bytes Root folder space in bytes by path
# TYPE readarr_rootfolder_freespace_bytes gauge
readarr_rootfolder_freespace_bytes{path="/media/books/",url="https://readarr.redacted.tld"} 3.7601424310272e+13
# HELP readarr_system_status System Status
# TYPE readarr_system_status gauge
readarr_system_status{url="https://readarr.redacted.tld"} 1

Benefits

Readarr Support, Yay!

Possible drawbacks

As Readarr is still nascent, there's a possibility their API may change.

Applicable issues

Additional information

Tested locally against a live readarr instance, Metric output above (with redacted url). I tried to follow the coding convention in other collectors, but glad to adjust style, etc if needed.

One possible issue identified -- I realized testing this that none of the *arrs actually enforce that the api key matches the validation regex in exportarr, it will accept any string (I noticed this because I generated api keys with lastpass as I preseed them in my kubernetes configs). I think this is likely something extremely specific to my setup, I'm planning to just cycle the keys to something the *arrs would generate, but thought I'd bring it up here in case you disagree, and think I should remove/adjust the validator.

Verified

This commit was signed with the committer’s verified signature.
spiffcs Christopher Angelo Phillips
Signed-off-by: Russell Troxel <russell.troxel@segment.com>
@rtrox rtrox requested a review from onedr0p as a code owner March 3, 2023 00:48
@onedr0p
Copy link
Owner

onedr0p commented Mar 3, 2023

Wow! Thanks for the PR. I'll review this tomorrow and provide any feed back if needed.

@onedr0p
Copy link
Owner

onedr0p commented Mar 4, 2023

I think this is likely something extremely specific to my setup, I'm planning to just cycle the keys to something the *arrs would generate, but thought I'd bring it up here in case you disagree, and think I should remove/adjust the validator.

I am pretty sure the arrs validate this on their side so it's not a bad idea.

@@ -94,13 +95,22 @@ func main() {
},
{
Name: "prowlarr",
Aliases: []string{"s"},
Aliases: []string{"p"},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@onedr0p onedr0p merged commit a2b6f15 into onedr0p:master Mar 4, 2023
@rtrox
Copy link
Collaborator Author

rtrox commented Mar 4, 2023

The *arrs probably should validate them, but they don't today 🫣 I changed my api keys to match what's generated, but sharing what I found here because I figured you might also get a kick out of it.

Today, it's just an unbounded string field. Since I'm running in k8s (as I think you are), I just seed in an api key, and before this PR, I'd just generated long strings with LastPass (uppercase & lowercase, 48 characters). The *arrs all happily accepted these api keys and set them in their SQLite dbs, and using the api works fine. I haven't tried to push it too far, but I'm pretty sure you could set your api key to "password" without *arr complaining. Readarr, Sonarr, Radarr, and Prowlarr, I don't use Lidarr, but I'd imagine that portion of the codebase is the same

@onedr0p
Copy link
Owner

onedr0p commented Mar 4, 2023

I'm using Kubernetes as well. I'm not sure if you saw but I build containers for certain things like the arrs and even template out the config.xml which allows you to use env for the settings in that file.

https://github.com/onedr0p/containers

Not sure if this simplifies your k8s deployments but I'm pretty happy with them :)

@rtrox
Copy link
Collaborator Author

rtrox commented Mar 4, 2023

I'm actually using your images already :-D I appreciate you building them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Readarr integration
2 participants