Rosler saw his side fall behind at Griffin Park when debutant Ben Nugent turned Josh Scott's wayward shot past his own goalkeeper but a change of shape and the introduction of El Alagui swung the match in favour of the Bees.
The 27-year-old drew the hosts level on the hour as he steered the ball home following a goalmouth scramble, with on-loan forward Martin Fillo rifling Brentford ahead shortly afterwards.
Sky Bet League Two side Dagenham hit back with 10 minutes remaining through Scott but El Alagui's header deep in to stoppage time ensured Brentford's progression and left his manager happy.
"With Farid in the team you know what you get, you get honesty and a guy who is determined to score at any cost," Rosler said.
"This is why he was the top scorer in the second-highest level in Scotland and why he scored two goals here. He goes in where it hurts and I think that was very important for us in getting through to the next round."
The former Falkirk frontman suffered a serious knee injury last October and fought his way back to fitness towards the end of the season.
"What he went through since last October - long, dark, heavy days in the pool and in the gym..." Rosler added.
"He came here to play football, has no family around and it was tough times. He never lost his spirit and worked and worked.
"Now he is getting more and more minutes and I'm sure we are getting him back to where he was before his injury."
- Sports & Recreation
- El Alagui
- Josh Scott