[GH-ISSUE #25] Multiple targets? #19

Closed
opened 2026-02-27 20:05:01 +03:00 by kerem · 5 comments
Owner

Originally created by @YouveGotMeowxy on GitHub (Dec 26, 2025).
Original GitHub issue: https://github.com/misiektoja/instagram_monitor/issues/25

Hi

I know that I can spawn many processes to monitor multiple targets, but wouldn't it be better and more elegant to be able to do it all with 1 process?

For example, just enter an array of targets, and the script will loop through that array?

Originally created by @YouveGotMeowxy on GitHub (Dec 26, 2025). Original GitHub issue: https://github.com/misiektoja/instagram_monitor/issues/25 Hi I know that I can spawn many processes to monitor multiple targets, but wouldn't it be better and more elegant to be able to do it all with 1 process? For example, just enter an array of targets, and the script will loop through that array?
kerem closed this issue 2026-02-27 20:05:01 +03:00
Author
Owner

@misiektoja commented on GitHub (Dec 27, 2025):

Hey, yes, this is a very good idea and you are not the first one asking for it. It has been on my mind for some time. Hopefully, I'll find time to implement it in the near future.

<!-- gh-comment-id:3693541667 --> @misiektoja commented on GitHub (Dec 27, 2025): Hey, yes, this is a very good idea and you are not the first one asking for it. It has been on my mind for some time. Hopefully, I'll find time to implement it in the near future.
Author
Owner

@misiektoja commented on GitHub (Dec 28, 2025):

Hey, I've found some time today and implemented the multi-user monitoring feature you requested. Here's what's been added:

  • Multi-user monitoring in one process: Monitor multiple Instagram users simultaneously without spawning separate processes
  • Automatic request staggering: Requests are automatically spread across your check interval to reduce the chance of triggering Instagram's anti-bot mechanisms
  • Per-user CSV files: When monitoring multiple users, each user gets their own CSV file (e.g., instagram_data_user1.csv, instagram_data_user2.csv) using your configured CSV filename as a prefix
  • Improved log file naming: Multi-target log files use sorted usernames joined with underscores (e.g., instagram_monitor_user1_user2_user3.log) to prevent filename collisions

How to Use

Simply pass multiple usernames as arguments:

instagram_monitor target_user_1 target_user_2 target_user_3

Or use the --targets flag with comma-separated values:

instagram_monitor --targets "target_user_1,target_user_2,target_user_3"

The tool will automatically stagger the start of each target's monitoring loop (spread across your INSTA_CHECK_INTERVAL by default). You can also control the staggering manually:

instagram_monitor target_user_1 target_user_2 --targets-stagger 300

This sets a 5-minute delay between each target's first poll.

When monitoring multiple users in a single process, the effective request rate is multiplied by the number of targets. For example, monitoring 5 users with a 1-hour interval means 5 requests per hour. To maintain the same per-account request rate, increase the check interval proportionally. If you normally use 1 hour for a single user, consider using 5 hours (or more) when monitoring 5 users. The tool automatically staggers requests between targets, but the overall request frequency should still be adjusted based on the total number of monitored users.

Configuration Options

You can also configure multi-target behavior in your config file:

  • TARGET_USERNAMES = ["user1", "user2"] - Define targets in config (CLI arguments take precedence)
  • MULTI_TARGET_STAGGER = 0 - Set to 0 for auto-spread, or specify seconds between targets
  • MULTI_TARGET_STAGGER_JITTER = 5 - Add random jitter (in seconds) to staggering
  • MULTI_TARGET_SERIALIZE_HTTP = True - Serialize HTTP requests across targets (enabled by default for safety)

Please test it out and let me know if it works as expected with your use case? Any issues or edge cases you encounter?

The feature is available in the latest beta v2.0 version on the dev branch: instagram_monitor.py

@tomballgithub - maybe you could also check it ? I think you also had a use case to monitor multiple users ...

<!-- gh-comment-id:3694947661 --> @misiektoja commented on GitHub (Dec 28, 2025): Hey, I've found some time today and implemented the multi-user monitoring feature you requested. Here's what's been added: - **Multi-user monitoring in one process**: Monitor multiple Instagram users simultaneously without spawning separate processes - **Automatic request staggering**: Requests are automatically spread across your check interval to reduce the chance of triggering Instagram's anti-bot mechanisms - **Per-user CSV files**: When monitoring multiple users, each user gets their own CSV file (e.g., `instagram_data_user1.csv`, `instagram_data_user2.csv`) using your configured CSV filename as a prefix - **Improved log file naming**: Multi-target log files use sorted usernames joined with underscores (e.g., `instagram_monitor_user1_user2_user3.log`) to prevent filename collisions ## How to Use Simply pass multiple usernames as arguments: `instagram_monitor target_user_1 target_user_2 target_user_3` Or use the `--targets` flag with comma-separated values: `instagram_monitor --targets "target_user_1,target_user_2,target_user_3"` The tool will automatically stagger the start of each target's monitoring loop (spread across your `INSTA_CHECK_INTERVAL` by default). You can also control the staggering manually: `instagram_monitor target_user_1 target_user_2 --targets-stagger 300` This sets a 5-minute delay between each target's first poll. When monitoring multiple users in a single process, the effective request rate is multiplied by the number of targets. For example, monitoring 5 users with a 1-hour interval means 5 requests per hour. To maintain the same per-account request rate, increase the check interval proportionally. If you normally use 1 hour for a single user, consider using 5 hours (or more) when monitoring 5 users. The tool automatically staggers requests between targets, but the overall request frequency should still be adjusted based on the total number of monitored users. ## Configuration Options You can also configure multi-target behavior in your config file: - `TARGET_USERNAMES = ["user1", "user2"]` - Define targets in config (CLI arguments take precedence) - `MULTI_TARGET_STAGGER = 0` - Set to 0 for auto-spread, or specify seconds between targets - `MULTI_TARGET_STAGGER_JITTER = 5` - Add random jitter (in seconds) to staggering - `MULTI_TARGET_SERIALIZE_HTTP = True` - Serialize HTTP requests across targets (enabled by default for safety) Please test it out and let me know if it works as expected with your use case? Any issues or edge cases you encounter? The feature is available in the latest beta v2.0 version on the dev branch: [instagram_monitor.py](https://raw.githubusercontent.com/misiektoja/instagram_monitor/refs/heads/dev/instagram_monitor.py) @tomballgithub - maybe you could also check it ? I think you also had a use case to monitor multiple users ...
Author
Owner

@tomballgithub commented on GitHub (Dec 28, 2025):

I'll add a 2nd account tonight to help test this. I need see how this works anyway for a few PR's I am working on

<!-- gh-comment-id:3695054755 --> @tomballgithub commented on GitHub (Dec 28, 2025): I'll add a 2nd account tonight to help test this. I need see how this works anyway for a few PR's I am working on
Author
Owner

@YouveGotMeowxy commented on GitHub (Jan 6, 2026):

I ran it for a few days on multiple targets and it seems to be working great so far. :)

Is there a way to tell the script where to save the stuff? Right now it seems to just dump everything into my User folder. I'm a bit of an organization freak and would love to be able to have it auto save to organized dirs. Like this (per target):

- Main dir
  - target 1 dir
     -- logs
     -- vids
     -- pics
  - target 2 dir
     -- logs
     -- vids
     -- pics

etc.

<!-- gh-comment-id:3714075640 --> @YouveGotMeowxy commented on GitHub (Jan 6, 2026): I ran it for a few days on multiple targets and it seems to be working great so far. :) Is there a way to tell the script where to save the stuff? Right now it seems to just dump everything into my User folder. I'm a bit of an organization freak and would love to be able to have it auto save to organized dirs. Like this (per target): ``` - Main dir - target 1 dir -- logs -- vids -- pics - target 2 dir -- logs -- vids -- pics ``` etc.
Author
Owner

@misiektoja commented on GitHub (Jan 6, 2026):

I ran it for a few days on multiple targets and it seems to be working great so far. :)

I'm glad to hear that! :-)

Is there a way to tell the script where to save the stuff? Right now it seems to just dump everything into my User folder

Lets continue in #35.

<!-- gh-comment-id:3715786301 --> @misiektoja commented on GitHub (Jan 6, 2026): > I ran it for a few days on multiple targets and it seems to be working great so far. :) > I'm glad to hear that! :-) > Is there a way to tell the script where to save the stuff? Right now it seems to just dump everything into my User folder > Lets continue in #35.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/instagram_monitor#19
No description provided.