Suppose you have
$$
\frac{\text{some polynomial}}{x^2 + x + 1}.
$$
Do long division and get
$$
\text{some polynomial} + \frac{\text{some first-degree polynomial}}{x^2+x+1}.
$$
In this case you get
$$
1 + \frac{-2x-1}{x^2+x+1}.
$$
First degree is the derivative of second degree, so $\dfrac{d}{dx}(x^2+x+1) = 2x+1$. So
\begin{align}
u & = x^2 + x + 1, \\[6pt]
du & = (2x+1)\,dx.
\end{align}
Then we have
$$
\int \left(1 - \frac 1 u \right) du.
$$
Somewhat more typically, one might have something like
$$
\frac{3x+5}{x^2+x+1}.
$$
Then one would write
$$
3x+5 = \frac 3 2 \left(2x + \frac{10}3\right)= \frac 3 2 \left((2x+1) + \frac 7 3\right)
$$
so we get
$$
\int\frac{3x+5}{x^2+x+1} \,dx=\frac 3 2 \int \frac{du}{u} + \frac 7 2 \int \frac{dx}{x^2+x+1}.
$$
That last integral would then need to get done by a different method, whose first step is completing the square.