Sertraline is an SSRI. That means a selective serotinin reuptake inhibitor. In simplest terms it blocks your body getting rid of serotonin a hormone that can be low in anxiety and depression. While commonly refered to as an "antidepressant", that term is a bit of a misnomer. SSRIs are used in depression, anxiety and obsessive compulsive disorder (the nasty life-derailing disorder, not the personality disorder of a similar name).
They rely on having a steady state of the medication in your body and can take up to 6 weeks to actually show positive effects, such as improved energy, appetite, improved mood, decrease anxiety and better sleep. The side effects are often very early on and resolve with time and are not limited to gastrointestinal distress, sedation and paradoxically agitation (sounds crazy but it can). These often resolve quickly.
In mild depression and anxiety, often talk based therapies are as effective or more so than medication. Things like counselling, cognitive behavioural therapy, bibliotherapy etc. However more severe conditions these interventions may not be effective until someone has been stable on a medication like an SSRI.
The common length of a first treatment is "Well plus 6months". It's not a quick fix like an antibiotic, but it isn't a lifelong thing. With each repeat bout of depression or anxiety the duration is usually extended. Some people choose to stay on them lifelong if they have had had several bad relapses.
For some people a particular medication isn't effective, in which most people trial swapping to a similar medication in the same class. This is often a lot easier as the body is used to the type of medication.
The most important pointed out above is you should go back and discuss this with your doctor, or another doctor you trust, a psychologist and/or a psychiatrist (though most depression or anxiety does not require a psychiatrist rather being capable of being managed by a family physican/General Practitioner rather than people on the internet.
Source: I'm a GP registrar.